diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md index 3ed85c1a90b69..b7b67a9f1d098 100644 --- a/src/doc/book/closures.md +++ b/src/doc/book/closures.md @@ -510,12 +510,11 @@ fn factory() -> Box 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 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