about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorRob Speer <rspeer+gh@luminoso.com>2017-01-19 02:51:29 -0500
committerRob Speer <rob@luminoso.com>2017-02-10 01:31:14 -0500
commit5cc5e0851e5bd14b9855462408ecb9058ed5eaad (patch)
tree2b73c3d644ff1b9b434ddf681a1d04d7c266c9a9 /src/libcore
parent24a70eb598a76edb0941f628a87946b40f2a1c83 (diff)
downloadrust-5cc5e0851e5bd14b9855462408ecb9058ed5eaad.tar.gz
rust-5cc5e0851e5bd14b9855462408ecb9058ed5eaad.zip
Fix a misleading statement in `Iterator.nth()`
The `Iterator.nth()` documentation says "Note that all preceding elements will be consumed". I assumed from that that the preceding elements would be the *only* ones that were consumed, but in fact the returned element is consumed as well.

The way I read the documentation, I assumed that `nth(0)` would not discard anything (as there are 0 preceding elements), so I added a sentence clarifying that it does. I also rephrased it to avoid the stunted "i.e." phrasing.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/iter/iterator.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs
index 3b406873d4b..0e14a93d253 100644
--- a/src/libcore/iter/iterator.rs
+++ b/src/libcore/iter/iterator.rs
@@ -209,7 +209,10 @@ pub trait Iterator {
 
     /// Returns the `n`th element of the iterator.
     ///
-    /// Note that all preceding elements will be consumed (i.e. discarded).
+    /// Note that all preceding elements, as well as the returned element, will be
+    /// consumed. That means that the preceding elements will be discarded, and also
+    /// that calling `nth(0)` multiple times on the same iterator will return different
+    /// objects.
     ///
     /// Like most indexing operations, the count starts from zero, so `nth(0)`
     /// returns the first value, `nth(1)` the second, and so on.