Skip to content

Commit

Permalink
Unrolled build for rust-lang#134576
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#134576 - hkBst:patch-4, r=jhpratt

Improve prose around basic examples of Iter and IterMut
  • Loading branch information
rust-timer authored Dec 21, 2024
2 parents 73c278f + a8e7a6c commit fc167e0
Showing 1 changed file with 12 additions and 6 deletions.
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

0 comments on commit fc167e0

Please sign in to comment.