fn foo() { ... } fn frobnicate(a: Bar, b: Bar, c: Bar, d: Bar) -> Bar { ... } trait Bar { fn baz(&self); } impl Bar for Baz { fn baz(&self) { ... } } frob(|x| { x.transpose() })
match
arms get braces, except for single-line expressions.match foo { bar => baz, quux => { do_something(); do_something_else() } }
return
statements get semicolons.fn foo() { do_something(); if condition() { return; } do_something_else(); }
fn main() { Foo { bar: 0, baz: 1 } Foo { bar: 0, baz: 1, } match a_thing { None => 0, Some(x) => 1, } }[FIXME] We should have a guideline for when to include trailing commas in
struct
s,match
es, function calls, etc.One possible rule: a trailing comma should be included whenever the closing delimiter appears on a separate line:
Foo { bar: 0, baz: 1 } Foo { bar: 0, baz: 1, } match a_thing { None => 0, Some(x) => 1, }