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
18 changes: 12 additions & 6 deletions library/core/src/slice/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ impl<'a, T> IntoIterator for &'a mut [T] {
/// Basic usage:
///
/// ```
/// // First, we declare a type which has `iter` method to get the `Iter` struct (`&[usize]` here):
/// // First, we need a slice to call the `iter` method on:
/// let slice = &[1, 2, 3];
///
/// // Then, we iterate over it:
/// // Then we call `iter` on the slice to get the `Iter` struct,
/// // and iterate over it:
/// for element in slice.iter() {
/// println!("{element}");
/// }
///
/// // This for loop actually already works without calling `iter`:
/// for element in slice {
/// println!("{element}");
/// }
/// ```
///
/// [`iter`]: slice::iter
Expand Down Expand Up @@ -166,11 +172,11 @@ impl<T> AsRef<[T]> for Iter<'_, T> {
/// Basic usage:
///
/// ```
/// // First, we declare a type which has `iter_mut` method to get the `IterMut`
/// // struct (`&[usize]` here):
/// let mut slice = &mut [1, 2, 3];
/// // First, we need a slice to call the `iter_mut` method on:
/// let slice = &mut [1, 2, 3];
///
/// // Then, we iterate over it and increment each element value:
/// // Then we call `iter_mut` on the slice to get the `IterMut` struct,
/// // iterate over it and increment each element value:
/// for element in slice.iter_mut() {
/// *element += 1;
/// }
Expand Down
Loading