Skip to content

Commit e51190c

Browse files
authored
Auto merge of #37024 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests - Successful merges: #36222, #36665, #36929, #37003, #37008 - Failed merges:
2 parents e2bd2d8 + 3e63076 commit e51190c

File tree

7 files changed

+366
-165
lines changed

7 files changed

+366
-165
lines changed

src/doc/reference.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -3110,10 +3110,12 @@ the lambda expression captures its environment by reference, effectively
31103110
borrowing pointers to all outer variables mentioned inside the function.
31113111
Alternately, the compiler may infer that a lambda expression should copy or
31123112
move values (depending on their type) from the environment into the lambda
3113-
expression's captured environment.
3113+
expression's captured environment. A lambda can be forced to capture its
3114+
environment by moving values by prefixing it with the `move` keyword.
31143115

31153116
In this example, we define a function `ten_times` that takes a higher-order
3116-
function argument, and we then call it with a lambda expression as an argument:
3117+
function argument, and we then call it with a lambda expression as an argument,
3118+
followed by a lambda expression that moves values from its environment.
31173119

31183120
```
31193121
fn ten_times<F>(f: F) where F: Fn(i32) {
@@ -3123,6 +3125,9 @@ fn ten_times<F>(f: F) where F: Fn(i32) {
31233125
}
31243126
31253127
ten_times(|j| println!("hello, {}", j));
3128+
3129+
let word = "konnichiwa".to_owned();
3130+
ten_times(move |j| println!("{}, {}", word, j));
31263131
```
31273132

31283133
### Infinite loops
@@ -3961,12 +3966,12 @@ implementation in the returned type `U`.
39613966

39623967
## The `Send` trait
39633968

3964-
The `Send` trait indicates that a value of this type is safe to send from one
3969+
The `Send` trait indicates that a value of this type is safe to send from one
39653970
thread to another.
39663971

3967-
## The 'Sync' trait
3972+
## The `Sync` trait
39683973

3969-
The 'Sync' trait indicates that a value of this type is safe to share between
3974+
The `Sync` trait indicates that a value of this type is safe to share between
39703975
multiple threads.
39713976

39723977
# Memory model

0 commit comments

Comments
 (0)