Skip to content

Commit ca83777

Browse files
authored
Merge pull request #1394 from shreepads/patch-1
Clarify distinction between for iter and into_iter
2 parents 10a3a86 + 4cc8565 commit ca83777

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/flow_control/for.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,20 @@ fn main() {
6767
for name in names.iter() {
6868
match name {
6969
&"Ferris" => println!("There is a rustacean among us!"),
70+
// TODO ^ Try deleting the & and matching just "Ferris"
7071
_ => println!("Hello {}", name),
7172
}
7273
}
74+
75+
println!("names: {:?}", names);
7376
}
7477
```
7578

7679
* `into_iter` - This consumes the collection so that on each iteration the exact
7780
data is provided. Once the collection has been consumed it is no longer
7881
available for reuse as it has been 'moved' within the loop.
7982

80-
```rust, editable
83+
```rust, editable, ignore
8184
fn main() {
8285
let names = vec!["Bob", "Frank", "Ferris"];
8386
@@ -87,6 +90,9 @@ fn main() {
8790
_ => println!("Hello {}", name),
8891
}
8992
}
93+
94+
println!("names: {:?}", names);
95+
// FIXME ^ Comment out this line
9096
}
9197
```
9298

0 commit comments

Comments
 (0)