rust_development
Rust systems programming, memory safety, Axum/Tokio ve WebAssembly rehberi.
npxskills add vuralserhat86/antigravity-agentic-skills--skill rust_developmentLoading…
Rust systems programming, memory safety, Axum/Tokio ve WebAssembly rehberi.
npxskills add vuralserhat86/antigravity-agentic-skills--skill rust_developmentLoading…
Rust systems programming rehberi.
// 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
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");
}
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();
}
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()
}
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
clippy'yi en sıkı modda (-D warnings) çalıştıracak şekilde CI pipeline'ına ekle.cargo-deny ile lisans ve güvenlik kontrolü yap.thiserror, uygulamalar için anyhow kullan. Asla unwrap() kullanma (testler hariç).tokio ve axum (veya actix-web) standartını benimse.struct UserId(Uuid)).tracing ve tracing-subscriber ile structured logging kur. println! kullanma.criterion ile benchmark testleri yaz.Cargo.toml içinde lto = true ve codegen-units = 1 ayarlarını yap.| 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? |
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).