+
+
+```
+fn main() {
+ let mut names = vec!["Bob", "Frank", "Ferris"];
+
+ for name in names.iter() {
+ match name {
+ &"Ferris" => println!("There is a rustacean among us!"),
+ _ => println!("Hello {}", name),
+ }
+ }
+
+ println!("names: {:?}", names);
+
+ for name in names.iter_mut() {
+ *name = match name {
+ &mut "Ferris" => "There is a rustacean among us!",
+ _ => "Hello",
+ }
+ }
+
+ println!("names: {:?}", names);
+
+ for name in names.into_iter() {
+ match name {
+ "Hello" => println!("Someone was normal"),
+ _ => println!("Warning: {}", name),
+ }
+ }
+ // names has moved here and is unusable:
+ // println!("names: {:?}", names); // compile error
+}
+```
+ |
+
+```
+fn main
+ let mut names = vec!["Bob", "Frank", "Ferris"]
+
+ for name from names
+ match name
+ &"Ferris" => println! "There is a rustacean among us!"
+ _ => println! "Hello {}", name
+
+ println!("names: {:?}", names);
+
+
+
+ for name on names
+ *name = match name
+ &mut "Ferris" => "There is a rustacean among us!"
+ _ => "Hello"
+
+ println!("names: {:?}", names);
+
+
+
+ for name in names
+ match name
+ "Hello" => println! "Someone was normal"
+ _ => println! "Warning: {}", name
+
+ // names has moved here and is unusable:
+ // println!("names: {:?}", names); // compile error
+
+
+
+```
+ |