Agent skill
rust-development-vuralserhat86-antigravity-agentic
Stars
163
Forks
31
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/rust-development-vuralserhat86-antigravity-agentic
SKILL.md
🦀 Rust Development
Rust systems programming rehberi.
📋 Temel Syntax
rust
// Variables
let x = 5; // Immutable
let mut y = 10; // Mutable
// Functions
fn add(a: i32, b: i32) -> i32 {
a + b // No semicolon = return
}
// Structs
struct User {
name: String,
age: u32,
}
// Enums
enum Status {
Active,
Inactive,
Pending(String),
}
🔒 Ownership & Borrowing
rust
// Ownership
let s1 = String::from("hello");
let s2 = s1; // s1 moved to s2
// Borrowing
fn print(s: &String) {
println!("{}", s);
}
// Mutable borrow
fn append(s: &mut String) {
s.push_str(" world");
}
⚡ Axum Web Framework
rust
use axum::{routing::get, Router, Json};
use serde::Serialize;
#[derive(Serialize)]
struct User { name: String }
async fn get_user() -> Json<User> {
Json(User { name: "John".into() })
}
#[tokio::main]
async fn main() {
let app = Router::new()
.route("/user", get(get_user));
axum::serve(listener, app).await.unwrap();
}
🔄 Async with Tokio
rust
use tokio;
#[tokio::main]
async fn main() {
let result = fetch_data().await;
}
async fn fetch_data() -> String {
tokio::time::sleep(Duration::from_secs(1)).await;
"data".to_string()
}
🎯 Error Handling
rust
use anyhow::Result;
use thiserror::Error;
#[derive(Error, Debug)]
enum AppError {
#[error("Not found: {0}")]
NotFound(String),
}
fn find_user(id: &str) -> Result<User> {
// Returns Result with anyhow
Ok(user)
}
Rust Development v1.1 - Enhanced
🔄 Workflow
Aşama 1: Project Setup & Structure
- Workspace: Büyük projeler için Cargo Workspace yapısını kur (Monorepo).
- Linter:
clippy'yi en sıkı modda (-D warnings) çalıştıracak şekilde CI pipeline'ına ekle. - Dependency Management:
cargo-denyile lisans ve güvenlik kontrolü yap.
Aşama 2: Implementation Patterns
- Error Handling: Kütüphaneler için
thiserror, uygulamalar içinanyhowkullan. Aslaunwrap()kullanma (testler hariç). - Async Runtime: Web sunucuları için
tokioveaxum(veyaactix-web) standartını benimse. - Type Safety: "Newtype Pattern" kullanarak primitive obsession'dan kaçın (
struct UserId(Uuid)).
Aşama 3: Performance & Reliability
- Tracing:
tracingvetracing-subscriberile structured logging kur.println!kullanma. - Benchmarks: Kritik fonksiyonlar için
criterionile benchmark testleri yaz. - Release Profile: Production build için
Cargo.tomliçindelto = truevecodegen-units = 1ayarlarını yap.
Kontrol Noktaları
| Aşama | Doğrulama |
|---|---|
| 1 | cargo clippy hatasız geçiyor mu? ve cargo fmt uygulandı mı? |
| 2 | Tüm public API'ler dökümante edildi mi? (/// doc comments). |
| 3 | Docker imajı distroless veya alpine tabanlı optimize edildi mi? |
Didn't find tool you were looking for?