1 // rustfmt-fn_single_line: true 2 // rustfmt-version: Two 3 // Test single-line functions. 4 foo_expr()5fn foo_expr() { 1 } 6 foo_stmt()7fn foo_stmt() { foo(); } 8 foo_decl_local()9fn foo_decl_local() { let z = 5; } 10 foo_decl_item(x: &mut i32)11fn foo_decl_item(x: &mut i32) { x = 3; } 12 empty()13fn empty() {} 14 foo_return() -> String15fn foo_return() -> String { "yay" } 16 foo_where() -> T where T: Sync,17fn foo_where() -> T 18 where 19 T: Sync, 20 { 21 let x = 2; 22 } 23 fooblock()24fn fooblock() { { "inner-block" } } 25 fooblock2(x: i32)26fn fooblock2(x: i32) { 27 let z = match x { 28 _ => 2, 29 }; 30 } 31 comment()32fn comment() { 33 // this is a test comment 34 1 35 } 36 comment2()37fn comment2() { 38 // multi-line comment 39 let z = 2; 40 1 41 } 42 only_comment()43fn only_comment() { 44 // Keep this here 45 } 46 aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name()47fn aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name() { 48 let z = "aaaaaaawwwwwwwwwwwwwwwwwwwwwwwwwwww"; 49 } 50 lots_of_space()51fn lots_of_space() { 1 } 52 mac() -> Vec<i32>53fn mac() -> Vec<i32> { vec![] } 54 55 trait CoolTypes { dummy(&self)56 fn dummy(&self) {} 57 } 58 59 trait CoolerTypes { dummy(&self)60 fn dummy(&self) {} 61 } 62 Foo<T>() where T: Bar,63fn Foo<T>() 64 where 65 T: Bar, 66 { 67 } 68