Agent Skills: Rust Conventions

>

UncategorizedID: liuchengxu/dotfiles/rust-conventions

Install this agent skill to your local

pnpm dlx add-skill https://github.com/liuchengxu/dotfiles/tree/HEAD/agents/skills/rust-conventions

Skill Files

Browse the full folder contents for rust-conventions.

Download Skill

Loading file tree…

agents/skills/rust-conventions/SKILL.md

Skill Metadata

Name
rust-conventions
Description
>

Rust Conventions

String Formatting

Use inline variable interpolation:

println!("Hello {name}");
format!("Processing {block_number} at slot {slot}");
error!("Failed to load {path}: {error}");

Positional {} placeholders are not used. This applies to every formatting macro: println!, format!, info!, warn!, error!, debug!, trace!, panic!, assert!, write!.

Import Organization

All use statements sit in a single consolidated group at the top of the file. Imports are never split mid-file or placed inside functions.

Checked Arithmetic

Value operations use checked arithmetic:

let result = value.checked_add(amount).ok_or(Error::Overflow)?;
let difference = total.checked_sub(fee).ok_or(Error::InsufficientFunds)?;

Bare +, -, * are reserved for arithmetic that carries no value semantics.

Function-Local Statics

A process-lifetime singleton whose only consumer is one function is declared inside that function:

static FOO: OnceCell<T> = OnceCell::const_new();

Put it inside get() rather than at module level when there is exactly one caller.

Before Committing

cargo +nightly fmt --all && cargo clippy