Removed commented main functions entirely. This fits in with other examples in the Closures section
This commit is contained in:
parent
32fb2527d9
commit
8483732c9a
@ -511,12 +511,10 @@ 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:
|
||||
@ -542,12 +540,10 @@ 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…
Reference in New Issue
Block a user