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