diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2014-09-10 18:30:28 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2014-09-10 18:30:28 -0400 |
| commit | c3943b3c89834db8cbeb7edc0a1e4b0002f11aa2 (patch) | |
| tree | 2e023ac4fad0c9f8e77649ed21abdd1c31044ed8 | |
| parent | 8f7470d86411c58d4ab256eb8a91394b5270032c (diff) | |
| download | rust-c3943b3c89834db8cbeb7edc0a1e4b0002f11aa2.tar.gz rust-c3943b3c89834db8cbeb7edc0a1e4b0002f11aa2.zip | |
don't say 'semantic'
| -rw-r--r-- | src/doc/guide.md | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/doc/guide.md b/src/doc/guide.md index 71f1c42f972..fc8279a778e 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -4271,14 +4271,14 @@ for num in nums.iter() { } ``` -There are two reasons for this. First, this is more semantic. We iterate -through the entire vector, rather than iterating through indexes, and then -indexing the vector. Second, this version is more efficient: the first version -will have extra bounds checking because it used indexing, `nums[i]`. But since -we yield a reference to each element of the vector in turn with the iterator, -there's no bounds checking in the second example. This is very common with -iterators: we can ignore unnecessary bounds checks, but still know that we're -safe. +There are two reasons for this. First, this more directly expresses what we +mean. We iterate through the entire vector, rather than iterating through +indexes, and then indexing the vector. Second, this version is more efficient: +the first version will have extra bounds checking because it used indexing, +`nums[i]`. But since we yield a reference to each element of the vector in turn +with the iterator, there's no bounds checking in the second example. This is +very common with iterators: we can ignore unnecessary bounds checks, but still +know that we're safe. There's another detail here that's not 100% clear because of how `println!` works. `num` is actually of type `&int`, that is, it's a reference to an `int`, |
