Skip to content

Commit

Permalink
Unrolled build for rust-lang#118586
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#118586 - gurry:118571-improve-slice-doc-example, r=thomcc

Improve example in `slice::windows()` doc

Fixes rust-lang#118571

Now using a window of 3 instead 2 because it removes any confusion about exactly how consecutive windows overlap
  • Loading branch information
rust-timer authored Dec 4, 2023
2 parents 0a83e43 + 423481b commit 5cb80d1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,11 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// let slice = ['r', 'u', 's', 't'];
/// let mut iter = slice.windows(2);
/// assert_eq!(iter.next().unwrap(), &['r', 'u']);
/// assert_eq!(iter.next().unwrap(), &['u', 's']);
/// assert_eq!(iter.next().unwrap(), &['s', 't']);
/// let slice = ['l', 'o', 'r', 'e', 'm'];
/// let mut iter = slice.windows(3);
/// assert_eq!(iter.next().unwrap(), &['l', 'o', 'r']);
/// assert_eq!(iter.next().unwrap(), &['o', 'r', 'e']);
/// assert_eq!(iter.next().unwrap(), &['r', 'e', 'm']);
/// assert!(iter.next().is_none());
/// ```
///
Expand Down

0 comments on commit 5cb80d1

Please sign in to comment.