@@ -179,7 +179,7 @@ also constant expressions:
179
179
* [ Index expressions] ( #index-expressions ) , indexing a [ array or
180
180
slice] ( types.html#array-and-slice-types ) with a ` usize ` .
181
181
* [ Range expressions] ( #range-expressions ) .
182
- * [ Lambda expressions] ( #lambda -expressions ) which don't capture variables from
182
+ * [ Closure expressions] ( #closure -expressions ) which don't capture variables from
183
183
the environment.
184
184
* Built in [ negation] ( #negation-operators ) , [ arithmetic,
185
185
logical] ( #arithmetic-and-logical-binary-operators ) ,
@@ -571,29 +571,29 @@ Refer to [RFC 132] for further details and motivations.
571
571
572
572
[ RFC 132 ] : https://github.com/rust-lang/rfcs/blob/master/text/0132-ufcs.md
573
573
574
- ## Lambda expressions
574
+ ## Closure expressions
575
575
576
- A _ lambda expression_ (sometimes called an "anonymous function expression")
577
- defines a closure and denotes it as a value, in a single expression. A lambda
576
+ A _ closure expression_ (sometimes called an "anonymous function expression")
577
+ defines a closure and denotes it as a value, in a single expression. A closure
578
578
expression is a pipe-symbol-delimited (` | ` ) list of patterns followed by an
579
579
expression. Type annotations may optionally be added for the type of the
580
580
parameters or for the return type. If there is a return type, the expression
581
- used for the body of the lambda must be a normal [ block] ( #block-expressions ) . A
582
- lambda expression also may begin with the ` move ` keyword before the initial
581
+ used for the body of the closure must be a normal [ block] ( #block-expressions ) .
582
+ A closure expression also may begin with the ` move ` keyword before the initial
583
583
` | ` .
584
584
585
- A lambda expression denotes a function that maps a list of parameters
585
+ A closure expression denotes a function that maps a list of parameters
586
586
(` ident_list ` ) onto the expression that follows the ` ident_list ` . The patterns
587
587
in the ` ident_list ` are the parameters to the closure. If a parameter's types
588
588
is not specified, then the compiler infers it from context. Each closure
589
589
expression has a unique anonymous type.
590
590
591
- Lambda expressions are most useful when passing functions as arguments to other
591
+ Closure expressions are most useful when passing functions as arguments to other
592
592
functions, as an abbreviation for defining and capturing a separate function.
593
593
594
- Significantly, lambda expressions _ capture their environment_ , which regular
594
+ Significantly, closure expressions _ capture their environment_ , which regular
595
595
[ function definitions] ( items.html#functions ) do not. Without the ` move `
596
- keyword, the lambda expression infers how it captures each variable from its
596
+ keyword, the closure expression infers how it captures each variable from its
597
597
environment, preferring to capture by shared reference, effectively borrowing
598
598
all outer variables mentioned inside the closure's body. If needed the compiler
599
599
will infer that instead mutable references should be taken, or that the values
@@ -610,8 +610,8 @@ traits allow functions to accept closures using generics, even though the exact
610
610
types can't be named.
611
611
612
612
In this example, we define a function ` ten_times ` that takes a higher-order
613
- function argument, and we then call it with a lambda expression as an argument,
614
- followed by a lambda expression that moves values from its environment.
613
+ function argument, and we then call it with a closure expression as an argument,
614
+ followed by a closure expression that moves values from its environment.
615
615
616
616
``` rust
617
617
fn ten_times <F >(f : F ) where F : Fn (i32 ) {
@@ -1069,7 +1069,7 @@ rather than are evaluated, so probably shouldn't be here. -->
1069
1069
| ` .. ` ` ... ` | Require parentheses |
1070
1070
| ` <- ` | right to left |
1071
1071
| ` = ` ` += ` ` -= ` ` *= ` ` /= ` ` %= ` ` &= ` <code >| ; =</code > ` ^= ` ` <<= ` ` >>= ` | right to left |
1072
- | ` return ` ` break ` ` continue ` <br >Lambda expressions | right to left |
1072
+ | ` return ` ` break ` ` continue ` <br >Closure expressions | right to left |
1073
1073
1074
1074
1075
1075
## Grouped expressions
0 commit comments