33> ** <sup >Syntax</sup >** \
44> _ ClosureExpression_ :\
55>   ;  ; ` move ` <sup >?</sup >\
6- >   ;  ; ( ` || ` | ` | ` [ _ FunctionParameters _ ] <sup >?</sup > ` | ` )\
6+ >   ;  ; ( ` || ` | ` | ` _ ClosureParameters _ <sup >?</sup > ` | ` )\
77>   ;  ; ([ _ Expression_ ] | ` -> ` [ _ TypeNoBounds_ ]   ; [ _ BlockExpression_ ] )
8+ >
9+ > _ ClosureParameters_ :\
10+ >   ;  ; _ ClosureParam_ (` , ` _ ClosureParam_ )<sup >\* </sup > ` , ` <sup >?</sup >
11+ >
12+ > _ ClosureParam_ :\
13+ >   ;  ; [ _ Pattern_ ]   ; ( ` : ` [ _ Type_ ] )<sup >?</sup >
814
915A _ closure expression_ defines a closure and denotes it as a value, in a single
1016expression. A closure expression is a pipe-symbol-delimited (` | ` ) list of
@@ -14,11 +20,11 @@ type, the expression used for the body of the closure must be a normal
1420[ block] . A closure expression also may begin with the
1521` move ` keyword before the initial ` | ` .
1622
17- A closure expression denotes a function that maps a list of parameters
18- ( ` ident_list ` ) onto the expression that follows the ` ident_list ` . The patterns
19- in the ` ident_list ` are the parameters to the closure. If a parameter's types
20- is not specified, then the compiler infers it from context . Each closure
21- expression has a unique anonymous type.
23+ A closure expression denotes a function that maps a list of parameters onto
24+ the expression that follows the parameters. Just like a [ ` let ` binding ] , the
25+ parameters are irrefutable [ patterns ] , whose type annotation is optional and
26+ will be inferred from context if not given . Each closure expression has a
27+ unique, anonymous type.
2228
2329Closure expressions are most useful when passing functions as arguments to other
2430functions, as an abbreviation for defining and capturing a separate function.
@@ -69,3 +75,6 @@ ten_times(move |j| println!("{}, {}", word, j));
6975[ _BlockExpression_ ] : expressions/block-expr.html
7076[ _TypeNoBounds_ ] : types.html#type-expressions
7177[ _FunctionParameters_ ] : items/functions.html
78+ [ _Pattern_ ] : patterns.html
79+ [ _Type_ ] : types.html#type-expressions
80+ [ `let` binding ] : statements.html#let-statements
0 commit comments