]> git.lizzy.rs Git - rust.git/commitdiff
Mention in the exact_chunks docs that this can often be optimized better by the compiler
authorSebastian Dröge <sebastian@centricular.com>
Tue, 9 Jan 2018 20:58:41 +0000 (22:58 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 13 Jan 2018 10:18:58 +0000 (12:18 +0200)
And also link from the normal chunks iterator to the exact_chunks one.

src/liballoc/slice.rs

index 182e9b0a00ed6077de1f4e14e5e7f61da53296c3..f8980b8777e93e3cfe2490c9b051c42904a66772 100644 (file)
@@ -613,6 +613,9 @@ pub fn windows(&self, size: usize) -> Windows<T> {
     /// not divide the length of the slice, then the last chunk will
     /// not have length `chunk_size`.
     ///
+    /// See [`exact_chunks`] for a variant of this iterator that returns chunks
+    /// of always exactly `chunk_size` elements.
+    ///
     /// # Panics
     ///
     /// Panics if `chunk_size` is 0.
@@ -638,6 +641,10 @@ pub fn chunks(&self, chunk_size: usize) -> Chunks<T> {
     /// not divide the length of the slice, then the last up to `chunk_size-1`
     /// elements will be omitted.
     ///
+    /// Due to each chunk having exactly `chunk_size` elements, the compiler
+    /// can often optimize the resulting code better than in the case of
+    /// [`chunks`].
+    ///
     /// # Panics
     ///
     /// Panics if `chunk_size` is 0.
@@ -664,6 +671,9 @@ pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
     /// not divide the length of the slice, then the last chunk will not
     /// have length `chunk_size`.
     ///
+    /// See [`exact_chunks_mut`] for a variant of this iterator that returns chunks
+    /// of always exactly `chunk_size` elements.
+    ///
     /// # Panics
     ///
     /// Panics if `chunk_size` is 0.
@@ -693,6 +703,11 @@ pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<T> {
     /// not divide the length of the slice, then the last up to `chunk_size-1`
     /// elements will be omitted.
     ///
+    ///
+    /// Due to each chunk having exactly `chunk_size` elements, the compiler
+    /// can often optimize the resulting code better than in the case of
+    /// [`chunks_mut`].
+    ///
     /// # Panics
     ///
     /// Panics if `chunk_size` is 0.