Skip to content

Commit f95b186

Browse files
committed
---
yaml --- r: 272792 b: refs/heads/beta c: a3c9afa h: refs/heads/master
1 parent 25b72c5 commit f95b186

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 9bf73d24d0fdc4f6dbca702ec85c5583abc921cd
26+
refs/heads/beta: a3c9afa841aba127edac2bb60e2f2a720a51d8ac
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/doc/book/vectors.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,37 @@ for i in v {
114114
println!("Take ownership of the vector and its element {}", i);
115115
}
116116
```
117-
Note: You cannot use the vector again once you have iterated with ownership of the vector.
118-
You can iterate the vector multiple times with reference iteration. For example, the following
119-
code does not compile.
117+
118+
Note: You cannot use the vector again once you have iterated by taking ownership of the vector.
119+
You can iterate the vector multiple times by taking a reference to the vector whilst iterating.
120+
For example, the following code does not compile.
121+
120122
```rust
121123
let mut v = vec![1, 2, 3, 4, 5];
124+
122125
for i in v {
123126
println!("Take ownership of the vector and its element {}", i);
124127
}
128+
125129
for i in v {
126130
println!("Take ownership of the vector and its element {}", i);
127131
}
128132
```
133+
129134
Whereas the following works perfectly,
130135

131136
```rust
132137
let mut v = vec![1, 2, 3, 4, 5];
138+
133139
for i in &v {
134-
println!("A mutable reference to {}", i);
140+
println!("This is a reference to {}", i);
135141
}
136142

137143
for i in &v {
138-
println!("A mutable reference to {}", i);
144+
println!("This is a reference {}", i);
139145
}
140146
```
147+
141148
Vectors have many more useful methods, which you can read about in [their
142149
API documentation][vec].
143150

0 commit comments

Comments
 (0)