From 634e6f6a1cd08f9d20a851040c4b77a1cc65c47e Mon Sep 17 00:00:00 2001 From: Ashok Gautham Date: Thu, 9 Apr 2020 19:16:40 +0530 Subject: [PATCH] Capture example should use String Using a `&'static str` like "green" would not prevent us from using the closure `print` post the move. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=411cb0b9776ece079c97d820ea6733ee --- src/fn/closures/capture.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fn/closures/capture.md b/src/fn/closures/capture.md index d4fa4eadc9..061ef1c7b2 100644 --- a/src/fn/closures/capture.md +++ b/src/fn/closures/capture.md @@ -16,7 +16,7 @@ required. fn main() { use std::mem; - let color = "green"; + let color = String::from("green"); // A closure to print `color` which immediately borrows (`&`) `color` and // stores the borrow and closure in the `print` variable. It will remain