RustRust Style Guide


Although there is no official Rust style guide, the following examples show the conventions adopted by most Rust projects. Following these conventions will align your project's style with that of the standard library, making it easier for people to see the logic in your code.


The official Rust style guidelines were available in the rust-lang/rust repository on GitHub, but they have recently been removed, pending migration to the rust-lang-nursery/fmt-rfcs repository. Until new guidelines are published there, you should try to follow the guidelines in the rust-lang repository.

You can use rustfmt and clippy to automatically review your code for style issues and format it correctly. These tools can be installed using Cargo, like so:

cargo install clippy
cargo install rustfmt

To run them, you use:

cargo clippy
cargo fmt