From 32fb2527d99f76b4bd41e7f4f0de5975c4ec7228 Mon Sep 17 00:00:00 2001 From: Bunts Thy Unholy Date: Mon, 31 Oct 2016 22:45:03 +1100 Subject: [PATCH 1/2] Commented out final 'main' function in order to fit within pattern of other examples and prevent incorrect indentation --- src/doc/book/closures.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md index 3ed85c1a90b69..b306ce5db169d 100644 --- a/src/doc/book/closures.md +++ b/src/doc/book/closures.md @@ -510,6 +510,7 @@ fn factory() -> Box i32> { Box::new(|x| x + num) } + # fn main() { let f = factory(); @@ -540,12 +541,13 @@ fn factory() -> Box i32> { Box::new(move |x| x + num) } -fn main() { + +# 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 From 8483732c9a01064028551e0f8ad454790f650a0f Mon Sep 17 00:00:00 2001 From: Bunts Thy Unholy Date: Mon, 31 Oct 2016 23:41:38 +1100 Subject: [PATCH 2/2] Removed commented main functions entirely. This fits in with other examples in the Closures section --- src/doc/book/closures.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md index b306ce5db169d..b7b67a9f1d098 100644 --- a/src/doc/book/closures.md +++ b/src/doc/book/closures.md @@ -511,12 +511,10 @@ 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: @@ -542,12 +540,10 @@ 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