From 84efbba2d5a66f96e8061e935f5b424dd3ad3723 Mon Sep 17 00:00:00 2001 From: Carson Rajcan Date: Wed, 6 Mar 2019 18:23:01 -0600 Subject: [PATCH] Mutate array in iter_mut() example --- src/flow_control/for.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/flow_control/for.md b/src/flow_control/for.md index 4205b002c4..a24228e8f2 100644 --- a/src/flow_control/for.md +++ b/src/flow_control/for.md @@ -99,11 +99,13 @@ fn main() { let mut names = vec!["Bob", "Frank", "Ferris"]; for name in names.iter_mut() { - match name { - &mut "Ferris" => println!("There is a rustacean among us!"), - _ => println!("Hello {}", name), + *name = match name { + &mut "Ferris" => "There is a rustacean among us!", + _ => "Hello", } } + + println!("names: {:?}", names); } ```