diff options
| author | Gurinder Singh <frederick.the.fool@gmail.com> | 2023-12-04 11:17:42 +0530 |
|---|---|---|
| committer | Gurinder Singh <frederick.the.fool@gmail.com> | 2023-12-04 11:17:42 +0530 |
| commit | 423481ba543ecaaae4a9484cb2e4fb0314e00204 (patch) | |
| tree | 2f7ff08d4489cabe7768eddf58dbe61c1d4234b2 | |
| parent | 85a4bd8f5873aa3ec5eb38baf63b89aa9bd21a7b (diff) | |
| download | rust-423481ba543ecaaae4a9484cb2e4fb0314e00204.tar.gz rust-423481ba543ecaaae4a9484cb2e4fb0314e00204.zip | |
Improve example in `slice::windows()` doc
Now using a window of 3 instead 2 because it removes any confusion about exactly how consecutive windows overlap
| -rw-r--r-- | library/core/src/slice/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 5957f9fd443..dec9f194863 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -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()); /// ``` /// |
