Skip to content

Commit

Permalink
Improve example in slice::windows() doc
Browse files Browse the repository at this point in the history
Now using a window of 3 instead 2 because it removes any
confusion about exactly how consecutive windows overlap
  • Loading branch information
gurry committed Dec 4, 2023
1 parent 85a4bd8 commit 423481b
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 423481b

Please sign in to comment.