Rollup merge of #118586 - gurry:118571-improve-slice-doc-example, r=thomcc
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
This commit is contained in:
commit
f1397e6ff2
1 changed files with 5 additions and 5 deletions
|
@ -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());
|
||||
/// ```
|
||||
///
|
||||
|
|
Loading…
Add table
Reference in a new issue