@@ -46,13 +46,19 @@ impl<'a, T> IntoIterator for &'a mut [T] {
4646/// Basic usage:
4747///
4848/// ```
49- /// // First, we declare a type which has `iter` method to get the `Iter` struct (`&[usize]` here) :
49+ /// // First, we need a slice to call the `iter` method on :
5050/// let slice = &[1, 2, 3];
5151///
52- /// // Then, we iterate over it:
52+ /// // Then we call `iter` on the slice to get the `Iter` struct,
53+ /// // and iterate over it:
5354/// for element in slice.iter() {
5455/// println!("{element}");
5556/// }
57+ ///
58+ /// // This for loop actually already works without calling `iter`:
59+ /// for element in slice {
60+ /// println!("{element}");
61+ /// }
5662/// ```
5763///
5864/// [`iter`]: slice::iter
@@ -166,11 +172,11 @@ impl<T> AsRef<[T]> for Iter<'_, T> {
166172/// Basic usage:
167173///
168174/// ```
169- /// // First, we declare a type which has `iter_mut` method to get the `IterMut`
170- /// // struct (`&[usize]` here):
171- /// let mut slice = &mut [1, 2, 3];
175+ /// // First, we need a slice to call the `iter_mut` method on:
176+ /// let slice = &mut [1, 2, 3];
172177///
173- /// // Then, we iterate over it and increment each element value:
178+ /// // Then we call `iter_mut` on the slice to get the `IterMut` struct,
179+ /// // iterate over it and increment each element value:
174180/// for element in slice.iter_mut() {
175181/// *element += 1;
176182/// }
0 commit comments