Skip to content

Commit

Permalink
Rollup merge of #118586 - gurry:118571-improve-slice-doc-example, r=t…
Browse files Browse the repository at this point in the history
…homcc

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

Fixes #118571

Now using a window of 3 instead 2 because it removes any confusion about exactly how consecutive windows overlap
  • Loading branch information
TaKO8Ki committed Dec 4, 2023
2 parents 30a4215 + 423481b commit f1397e6
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 f1397e6

Please sign in to comment.