File tree Expand file tree Collapse file tree
content/lessons/06_closures_iterators Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11fn main ( ) {
22 #[ rustfmt:: skip]
33 {
4- // This is formatted so that with rust-analyzer it renders as well-aligned.
4+ // This is formatted so that without rust-analyzer it renders as well-aligned.
55
6- fn add_one_v1 ( x : u32 ) -> u32 { x + 1 } // This is an ordinary function.
6+ fn add_one_v1 ( x : u32 ) -> u32 { x + 1 } // This is an ordinary function.
77 let add_one_v2 = |x : u32 | -> u32 { x + 1 } ; // Closures use pipes instead of parentheses.
8- let add_one_v3 = |x| { x + 1 } ; // Both parameters and return value can have their types inferred.
9- let add_one_v4 = |x| x + 1 ; // If the body is a single expression, braces can be omitted.
8+ let add_one_v3 = |x| { x + 1 } ; // Both parameters and return value can have their types inferred.
9+ let add_one_v4 = |x| x + 1 ; // If the body is a single expression, braces can be omitted.
1010
1111 let _res = add_one_v1 ( 0_u32 ) ;
1212 let _res = add_one_v2 ( 0_u32 ) ;
You can’t perform that action at this time.
0 commit comments