@@ -109,19 +109,25 @@ impl<'a, T> Iter<'a, T> {
109
109
/// Basic usage:
110
110
///
111
111
/// ```
112
- /// // First, we declare a type which has the `iter` method to get the `Iter`
112
+ /// // First, we need a slice to call the `iter` method on:
113
113
/// // struct (`&[usize]` here):
114
114
/// let slice = &[1, 2, 3];
115
115
///
116
- /// // Then, we get the iterator :
116
+ /// // Then we call `iter` on the slice to get the `Iter` struct :
117
117
/// let mut iter = slice.iter();
118
- /// // So if we print what `as_slice` method returns here, we have "[1, 2, 3]":
118
+ /// // Here `as_slice` still returns the whole slice, so this prints "[1, 2, 3]":
119
119
/// println!("{:?}", iter.as_slice());
120
120
///
121
- /// // Next , we move to the second element of the slice :
121
+ /// // Now , we call the `next` method to remove the first element of the iterator :
122
122
/// iter.next();
123
- /// // Now `as_slice` returns "[2, 3]":
123
+ /// // Here the iterator does not contain the first element of the slice any more,
124
+ /// // so `as_slice` only returns the last two elements of the slice,
125
+ /// // and so this prints "[2, 3]":
124
126
/// println!("{:?}", iter.as_slice());
127
+ ///
128
+ /// // The underlying slice has not been modified and still contains three elements,
129
+ /// // so this prints "[1, 2, 3]":
130
+ /// println!("{:?}", slice);
125
131
/// ```
126
132
#[ must_use]
127
133
#[ stable( feature = "iter_to_slice" , since = "1.4.0" ) ]
0 commit comments