← ClaudeAtlas

rust-code-stylelisted

Rust source layout and readability rules — module file layout, lib.rs re-export policy, visibility levels, item order inside a file, import grouping, function structure, error-handling crate choice, and naming. Use when you create a module or a crate, add or move a source file, decide what to make pub, order items in a file, clean up imports, or review a diff for structure and readability.
po4yka/rust-skills · ★ 2 · Code & Development · score 76
Install: claude install-skill po4yka/rust-skills
# Rust Code Style ## Purpose Code is technical writing for future readers. Lead with the most important details. Keep related things close together. These rules are adapted from the [epage Rust Style Guide](https://epage.github.io/dev/rust-style/). Use this skill when you: - Create a new crate or a new module. - Add, split, or move a source file. - Decide the visibility of an item. - Order items inside a file, or clean up imports. - Review a diff for structure and readability. This skill covers the decisions `rustfmt` cannot make for you. `rustfmt` owns line width, brace placement, and wrapping. Lint tables, `clippy.toml`, and `rustfmt.toml` live in `rust-lints`. Crate boundaries and dependency direction live in `rust-crate-architecture`. --- ## Module layout Use `name.rs` next to a `name/` directory for every module that has children. Use `mod.rs` only three levels deep or more, and never mix the two patterns at one directory level. `lib.rs` declares the modules first, then re-exports the public API item by item, with no glob. A `pub mod prelude` is the one module a caller may glob-import. Keep it short. Avoid `#[path]`. The file tree, the `lib.rs` example, the prelude collision (E0659), and the `build.rs` exception are in [references/module-layout.md](references/module-layout.md). --- ## Visibility Use three levels only. Nothing else. | Level | When to use | |-------|-------------| | private (default) | An implementation detail inside one module | | `pub(crate