Skip to content

Commit 634e6f6

Browse files
authored
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
1 parent c106d16 commit 634e6f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/fn/closures/capture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ required.
1616
fn main() {
1717
use std::mem;
1818
19-
let color = "green";
19+
let color = String::from("green");
2020
2121
// A closure to print `color` which immediately borrows (`&`) `color` and
2222
// stores the borrow and closure in the `print` variable. It will remain

0 commit comments

Comments
 (0)