Skip to content

Commit

Permalink
Rollup merge of #37495 - buntine:master, r=steveklabnik
Browse files Browse the repository at this point in the history
Commented out final 'main' function in order to fit within pattern of…

… other examples and prevent incorrect indentation
  • Loading branch information
GuillaumeGomez authored Nov 1, 2016
2 parents d2f5d26 + 8483732 commit f5c192a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/doc/book/closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit f5c192a

Please sign in to comment.