@@ -4271,14 +4271,14 @@ for num in nums.iter() {
4271
4271
}
4272
4272
```
4273
4273
4274
- There are two reasons for this. First, this is more semantic. We iterate
4275
- through the entire vector, rather than iterating through indexes, and then
4276
- indexing the vector. Second, this version is more efficient: the first version
4277
- will have extra bounds checking because it used indexing, ` nums[i] ` . But since
4278
- we yield a reference to each element of the vector in turn with the iterator,
4279
- there's no bounds checking in the second example. This is very common with
4280
- iterators: we can ignore unnecessary bounds checks, but still know that we're
4281
- safe.
4274
+ There are two reasons for this. First, this more directly expresses what we
4275
+ mean. We iterate through the entire vector, rather than iterating through
4276
+ indexes, and then indexing the vector. Second, this version is more efficient:
4277
+ the first version will have extra bounds checking because it used indexing,
4278
+ ` nums[i] ` . But since we yield a reference to each element of the vector in turn
4279
+ with the iterator, there's no bounds checking in the second example. This is
4280
+ very common with iterators: we can ignore unnecessary bounds checks, but still
4281
+ know that we're safe.
4282
4282
4283
4283
There's another detail here that's not 100% clear because of how ` println! `
4284
4284
works. ` num ` is actually of type ` &int ` , that is, it's a reference to an ` int ` ,
0 commit comments