• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // rustfmt-fn_single_line: true
2 // rustfmt-version: Two
3 // Test single-line functions.
4 
foo_expr()5 fn foo_expr() { 1 }
6 
foo_stmt()7 fn foo_stmt() { foo(); }
8 
foo_decl_local()9 fn foo_decl_local() { let z = 5; }
10 
foo_decl_item(x: &mut i32)11 fn foo_decl_item(x: &mut i32) { x = 3; }
12 
empty()13 fn empty() {}
14 
foo_return() -> String15 fn foo_return() -> String { "yay" }
16 
foo_where() -> T where T: Sync,17 fn foo_where() -> T
18 where
19     T: Sync,
20 {
21     let x = 2;
22 }
23 
fooblock()24 fn fooblock() { { "inner-block" } }
25 
fooblock2(x: i32)26 fn fooblock2(x: i32) {
27     let z = match x {
28         _ => 2,
29     };
30 }
31 
comment()32 fn comment() {
33     // this is a test comment
34     1
35 }
36 
comment2()37 fn comment2() {
38     // multi-line comment
39     let z = 2;
40     1
41 }
42 
only_comment()43 fn only_comment() {
44     // Keep this here
45 }
46 
aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name()47 fn aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name() {
48     let z = "aaaaaaawwwwwwwwwwwwwwwwwwwwwwwwwwww";
49 }
50 
lots_of_space()51 fn lots_of_space() { 1 }
52 
mac() -> Vec<i32>53 fn 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,63 fn Foo<T>()
64 where
65     T: Bar,
66 {
67 }
68