Skip to content

Commit

Permalink
Merge pull request #1165 from crajcan/edit-for-loop-mutation-example
Browse files Browse the repository at this point in the history
Mutate array in iter_mut() example
  • Loading branch information
marioidival committed Apr 15, 2019
2 parents 22bb226 + 84efbba commit 8899358
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/flow_control/for.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
```

Expand Down

0 comments on commit 8899358

Please sign in to comment.