skills/coding/coding-rust/SKILL.md
Rust: ownership/borrowing/lifetimes, traits, tokio async, anyhow/thiserror, cargo workspaces, unsafe
npx skillsauth add alphaonedev/openclaw-graph coding-rustInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides expertise in advanced Rust programming, focusing on core language features and ecosystem tools to build efficient, safe systems code.
trait Debug { fn fmt(&self); }.tokio::main and futures.Cargo.toml workspaces for dependency sharing.&mut T for mutable references and ensure lifetimes match, e.g., in functions like fn borrow lifetimes<'a>(x: &'a i32) -> &'a i32.tokio::spawn to run futures concurrently, then await results in an async main function.impl MyTrait for MyStruct { fn method() { ... } }.Cargo.toml, add [workspace] section with members = ["crate1", "crate2"], then build with cargo build --workspace.anyhow::Result and propagate them using ? operator.unsafe { *ptr = value; } and justify with comments.cargo build --release for optimized binaries; test with cargo test --workspace for all crates; add dependencies via cargo add tokio --features full.#[tokio::main] async fn main() { tokio::spawn(async { ... }); }; use channels for async communication, e.g., let (tx, rx) = tokio::sync::mpsc::channel(10);.#[derive(thiserror::Error)] enum MyError { ... }; handle in functions as fn example() -> anyhow::Result<()> { ... }.std::mem::drop to explicitly drop values, or std::borrow::Cow for owned/copied data.Cargo.toml for project settings, e.g., [dependencies] tokio = { version = "1.0", features = ["full"] }; use environment variables for secrets like RUST_BACKTRACE=1 for debugging.$RUSTUP_TOOLCHAIN env var to switch Rust versions, e.g., export RUSTUP_TOOLCHAIN=nightly for unstable features.$MY_API_KEY and access via std::env::var("MY_API_KEY").unwrap().cargo fmt for code formatting and cargo clippy for lints before builds.Cargo.toml, then import in code with use tokio::runtime::Runtime; let rt = Runtime::new().unwrap(); rt.block_on(async { ... });.Cargo.toml, use path = "../sibling_crate".anyhow::Result<T> from functions and use ? to handle errors, e.g., fn read_file() -> anyhow::Result<String> { std::fs::read_to_string("file.txt").context("Failed to read") }.#[derive(thiserror::Error, Debug)] enum AppError { #[error("IO error: {0}")] Io(#[from] std::io::Error), } and handle with match statements..await.map_err(|e| anyhow::Error::from(e)).std::panic::catch_unwind around unsafe blocks to prevent crashes.Cargo.toml, then write: use tokio::net::TcpListener; #[tokio::main] async fn main() -> anyhow::Result<()> { let listener = TcpListener::bind("127.0.0.1:8080").await?; loop { let (socket, _) = listener.accept().await?; tokio::spawn(handle_connection(socket)); } }.Cargo.toml, add anyhow = "1.0" and thiserror = "1.0", then implement: use thiserror::Error; #[derive(Error, Debug)] enum Error { #[error("Parse error")] Parse, } fn main() -> anyhow::Result<()> { let input = std::env::args().nth(1)?; if input.parse::<u32>().is_err() { Err(Error::Parse)?; } Ok(()) }.tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui