Rollup merge of #37495 - buntine:master, r=steveklabnik
Commented out final 'main' function in order to fit within pattern of… … other examples and prevent incorrect indentation
This commit is contained in:
commit
f5c192a4b7
@ -510,12 +510,11 @@ fn factory() -> Box<Fn(i32) -> i32> {
|
||||
|
||||
Box::new(|x| x + num)
|
||||
}
|
||||
# fn main() {
|
||||
|
||||
let f = factory();
|
||||
|
||||
let answer = f(1);
|
||||
assert_eq!(6, answer);
|
||||
# }
|
||||
```
|
||||
|
||||
There’s just one last problem:
|
||||
@ -540,12 +539,11 @@ fn factory() -> Box<Fn(i32) -> i32> {
|
||||
|
||||
Box::new(move |x| x + num)
|
||||
}
|
||||
fn main() {
|
||||
|
||||
let f = factory();
|
||||
|
||||
let answer = f(1);
|
||||
assert_eq!(6, answer);
|
||||
}
|
||||
```
|
||||
|
||||
By making the inner closure a `move Fn`, we create a new stack frame for our
|
||||
|
Loading…
x
Reference in New Issue
Block a user