about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2023-12-04 21:19:45 +0900
committerGitHub <noreply@github.com>2023-12-04 21:19:45 +0900
commitf1397e6ff2b3fa8e6efa4815f603d055c172432d (patch)
tree8f9139d17b86803522fed006471c5169293e21c3
parent30a4215532ac4fc51fc8139a76c996b8bb4da549 (diff)
parent423481ba543ecaaae4a9484cb2e4fb0314e00204 (diff)
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
-rw-r--r--library/core/src/slice/mod.rs10
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());
     /// ```
     ///