Skip to content

Commit 8a82e8e

Browse files
committed
Mention in the exact_chunks docs that this can often be optimized better by the compiler
And also link from the normal chunks iterator to the exact_chunks one.
1 parent 6bf1dfd commit 8a82e8e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/liballoc/slice.rs

+15
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,9 @@ impl<T> [T] {
613613
/// not divide the length of the slice, then the last chunk will
614614
/// not have length `chunk_size`.
615615
///
616+
/// See [`exact_chunks`] for a variant of this iterator that returns chunks
617+
/// of always exactly `chunk_size` elements.
618+
///
616619
/// # Panics
617620
///
618621
/// Panics if `chunk_size` is 0.
@@ -638,6 +641,10 @@ impl<T> [T] {
638641
/// not divide the length of the slice, then the last up to `chunk_size-1`
639642
/// elements will be omitted.
640643
///
644+
/// Due to each chunk having exactly `chunk_size` elements, the compiler
645+
/// can often optimize the resulting code better than in the case of
646+
/// [`chunks`].
647+
///
641648
/// # Panics
642649
///
643650
/// Panics if `chunk_size` is 0.
@@ -664,6 +671,9 @@ impl<T> [T] {
664671
/// not divide the length of the slice, then the last chunk will not
665672
/// have length `chunk_size`.
666673
///
674+
/// See [`exact_chunks_mut`] for a variant of this iterator that returns chunks
675+
/// of always exactly `chunk_size` elements.
676+
///
667677
/// # Panics
668678
///
669679
/// Panics if `chunk_size` is 0.
@@ -693,6 +703,11 @@ impl<T> [T] {
693703
/// not divide the length of the slice, then the last up to `chunk_size-1`
694704
/// elements will be omitted.
695705
///
706+
///
707+
/// Due to each chunk having exactly `chunk_size` elements, the compiler
708+
/// can often optimize the resulting code better than in the case of
709+
/// [`chunks_mut`].
710+
///
696711
/// # Panics
697712
///
698713
/// Panics if `chunk_size` is 0.

0 commit comments

Comments
 (0)