#[deprecated = "Use `bar` instead."] fn foo(a: usize, b: usize) -> usize { a + b }
fn foo(a: Bar); MyStruct { foo: 3, bar: 4 } foo(bar, baz);
struct
expressions:spawn(proc() { do_something(); }) Point { x: 0.1, y: 0.3 }
fn frobnicate(a: Bar, b: Bar, c: Bar, d: Bar) -> Bar { ... } fn foo<T: This, U: That>( a: Bar, b: Bar) -> Baz { ... }
fn foo_bar(a: Bar, b: Bar, c: |Bar|) -> Bar { ... } // Same line is fine: foo_bar(x, y, |z| { z.transpose(y) }); // Indented body on new line is also fine: foo_bar(x, y, |z| { z.quux(); z.rotate(x) })
[FIXME] Do we also want to allow the following?
fn main() { frobnicate( arg1, arg2, arg3) }frobnicate( arg1, arg2, arg3)This style could ease the conflict between line length and functions with many parameters (or long method chains).
[Deprecated] If you have multiple patterns in a single
fn main() { match foo { bar(_) | baz => quux, x | y | z => { quuux } } }match
arm, write each pattern on a separate line:match foo { bar(_) | baz => quux, x | y | z => { quuux } }
Idiomatic code should not use extra whitespace in the middle of a line to provide alignment.
fn main() { // Good struct Foo { short: f64, really_long: f64, } // Bad struct Bar { short: f64, really_long: f64, } // Good let a = 0; let radius = 7; // Bad let b = 0; let diameter = 7; }// Good struct Foo { short: f64, really_long: f64, } // Bad struct Bar { short: f64, really_long: f64, } // Good let a = 0; let radius = 7; // Bad let b = 0; let diameter = 7;