Content-Length: 24536 | pFad | https://doc.rust-lang.org/std/iter/../../std/string/../../style-guide/advice.html

Other style advice - The Rust Style Guide

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Other style advice

Expressions

Prefer to use Rust’s expression oriented nature where possible;

#![allow(unused)]
fn main() {
// use
let x = if y { 1 } else { 0 };
// not
let x;
if y {
    x = 1;
} else {
    x = 0;
}
}

Names

  • Types shall be UpperCamelCase,
  • Enum variants shall be UpperCamelCase,
  • Struct fields shall be snake_case,
  • Function and method names shall be snake_case,
  • Local variables shall be snake_case,
  • Macro names shall be snake_case,
  • Constants (consts and immutable statics) shall be SCREAMING_SNAKE_CASE.
  • When a name is forbidden because it is a reserved word (such as crate), either use a raw identifier (r#crate) or use a trailing underscore (crate_). Don’t misspell the word (krate).

Modules

Avoid #[path] annotations where possible.









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://doc.rust-lang.org/std/iter/../../std/string/../../style-guide/advice.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy