rust-idioms

Catalogs idiomatic Rust naming conventions, constructs, and anti-patterns for writing native-style code.

3|Updated Aug 8, 2026
One-click install
npx skills add https://github.com/Jose-Polanco-Oxte/Echos-Live-Music-Visualizer --skill rust-idioms-jose-polanco-oxte
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-idioms
Source: https://github.com/Jose-Polanco-Oxte/Echos-Live-Music-Visualizer/tree/main/.agents/skills/rust/sub-skills/rust-idioms
Command: npx skills add https://github.com/Jose-Polanco-Oxte/Echos-Live-Music-Visualizer --skill rust-idioms-jose-polanco-oxte

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust code that compiles but reads like ported Java or C++ is hard to review and maintain. This Skill provides a reference catalog of naming conventions, idiomatic constructs, and common anti-patterns so you can write Rust that the ecosystem recognizes as native and catch code smells during review. ## Core Features & Use Cases - Naming Conventions: Applies the Rust API Guidelines for types, functions, conversions (as_/to_/into_), iterators, and constructors. - Idiomatic Construct Catalog: Covers From/TryFrom conversions, Default + struct-update, iterator chains, concise control flow (let ... else, matches!), derive ordering, and minimal visibility. - Anti-Pattern Detection: Flags smells like unwrap() on reachable paths, &Vec<T> parameters, stringly-typed data, premature Arc<Mutex<T>>, and Deref used to fake inheritance, each with the fix. - Use Case: While reviewing a pull request, you spot fn process(data: &Vec<String>) and a wildcard match on a domain enum. Use this Skill to identify both as anti-patterns and apply the slice-parameter and exhaustive-match fixes. ## Quick Start Review my Rust function for idiomatic style and flag any anti-patterns like unwrap usage, &Vec parameters, or stringly-typed arguments.

Frequently Asked Questions about rust-idioms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write idiomatic Rust code?

Follow the Rust API Guidelines for naming (snake_case functions, UpperCamelCase types), implement From/TryFrom for conversions, prefer iterator chains over index loops, and accept &str or slices instead of owned types. Run cargo clippy with pedantic lints and cargo fmt to enforce style automatically.

What are common Rust anti-patterns to avoid?

Common smells include unwrap() on reachable paths, cloning to satisfy the borrow checker, &Vec<T> or &String parameters, stringly-typed data instead of enums, boolean parameters, premature Arc<Mutex<T>>, and using Deref to fake inheritance. Each has a standard fix such as borrowing, slices, or typed errors.

Should I use clippy pedantic lints in my Rust project?

Yes, enable all and pedantic clippy groups in Cargo.toml and run cargo clippy --all-targets with -D warnings in CI. Avoid baking #![deny(warnings)] into source, since future compiler lints would break downstream builds; enforce it in CI where the toolchain is pinned.

When should I use From instead of a custom conversion method?

Implement From (or TryFrom for fallible cases) whenever converting between types, since Into comes free and it plugs into generic bounds, the ? operator, and .into() calls. Custom to_x or from_x methods are appropriate only when a trait impl does not fit.

Why is using Deref for inheritance a bad idea in Rust?

Deref is meant for smart pointers that are a pointer to their Target, not for exposing a field's methods. Using it to fake inheritance leaks every Target method onto your type, breaks when you add a same-named inherent method, and confuses readers; expose explicit methods instead.