Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions library/core/src/slice/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,25 @@ impl<'a, T> Iter<'a, T> {
/// Basic usage:
///
/// ```
/// // First, we declare a type which has the `iter` method to get the `Iter`
/// // First, we need a slice to call the `iter` method on:
/// // struct (`&[usize]` here):
/// let slice = &[1, 2, 3];
///
/// // Then, we get the iterator:
/// // Then we call `iter` on the slice to get the `Iter` struct:
/// let mut iter = slice.iter();
/// // So if we print what `as_slice` method returns here, we have "[1, 2, 3]":
/// // Here `as_slice` still returns the whole slice, so this prints "[1, 2, 3]":
/// println!("{:?}", iter.as_slice());
///
/// // Next, we move to the second element of the slice:
/// // Now, we call the `next` method to remove the first element of the iterator:
/// iter.next();
/// // Now `as_slice` returns "[2, 3]":
/// // Here the iterator does not contain the first element of the slice any more,
/// // so `as_slice` only returns the last two elements of the slice,
/// // and so this prints "[2, 3]":
/// println!("{:?}", iter.as_slice());
///
/// // The underlying slice has not been modified and still contains three elements,
/// // so this prints "[1, 2, 3]":
/// println!("{:?}", slice);
/// ```
#[must_use]
#[stable(feature = "iter_to_slice", since = "1.4.0")]
Expand Down
Loading