Skip to content

Commit 6eafab0

Browse files
committed
Auto merge of #51151 - sdroege:exact-chunks-docs-order, r=dtolnay
Move slice::exact_chunks directly above exact_chunks_mut for more con… …sistent docs order See #47115 (comment)
2 parents 6232478 + eb3a734 commit 6eafab0

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/libcore/slice/mod.rs

+35-35
Original file line numberDiff line numberDiff line change
@@ -691,41 +691,6 @@ impl<T> [T] {
691691
Chunks { v: self, chunk_size: chunk_size }
692692
}
693693

694-
/// Returns an iterator over `chunk_size` elements of the slice at a
695-
/// time. The chunks are slices and do not overlap. If `chunk_size` does
696-
/// not divide the length of the slice, then the last up to `chunk_size-1`
697-
/// elements will be omitted.
698-
///
699-
/// Due to each chunk having exactly `chunk_size` elements, the compiler
700-
/// can often optimize the resulting code better than in the case of
701-
/// [`chunks`].
702-
///
703-
/// # Panics
704-
///
705-
/// Panics if `chunk_size` is 0.
706-
///
707-
/// # Examples
708-
///
709-
/// ```
710-
/// #![feature(exact_chunks)]
711-
///
712-
/// let slice = ['l', 'o', 'r', 'e', 'm'];
713-
/// let mut iter = slice.exact_chunks(2);
714-
/// assert_eq!(iter.next().unwrap(), &['l', 'o']);
715-
/// assert_eq!(iter.next().unwrap(), &['r', 'e']);
716-
/// assert!(iter.next().is_none());
717-
/// ```
718-
///
719-
/// [`chunks`]: #method.chunks
720-
#[unstable(feature = "exact_chunks", issue = "47115")]
721-
#[inline]
722-
pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
723-
assert!(chunk_size != 0);
724-
let rem = self.len() % chunk_size;
725-
let len = self.len() - rem;
726-
ExactChunks { v: &self[..len], chunk_size: chunk_size}
727-
}
728-
729694
/// Returns an iterator over `chunk_size` elements of the slice at a time.
730695
/// The chunks are mutable slices, and do not overlap. If `chunk_size` does
731696
/// not divide the length of the slice, then the last chunk will not
@@ -761,6 +726,41 @@ impl<T> [T] {
761726
ChunksMut { v: self, chunk_size: chunk_size }
762727
}
763728

729+
/// Returns an iterator over `chunk_size` elements of the slice at a
730+
/// time. The chunks are slices and do not overlap. If `chunk_size` does
731+
/// not divide the length of the slice, then the last up to `chunk_size-1`
732+
/// elements will be omitted.
733+
///
734+
/// Due to each chunk having exactly `chunk_size` elements, the compiler
735+
/// can often optimize the resulting code better than in the case of
736+
/// [`chunks`].
737+
///
738+
/// # Panics
739+
///
740+
/// Panics if `chunk_size` is 0.
741+
///
742+
/// # Examples
743+
///
744+
/// ```
745+
/// #![feature(exact_chunks)]
746+
///
747+
/// let slice = ['l', 'o', 'r', 'e', 'm'];
748+
/// let mut iter = slice.exact_chunks(2);
749+
/// assert_eq!(iter.next().unwrap(), &['l', 'o']);
750+
/// assert_eq!(iter.next().unwrap(), &['r', 'e']);
751+
/// assert!(iter.next().is_none());
752+
/// ```
753+
///
754+
/// [`chunks`]: #method.chunks
755+
#[unstable(feature = "exact_chunks", issue = "47115")]
756+
#[inline]
757+
pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
758+
assert!(chunk_size != 0);
759+
let rem = self.len() % chunk_size;
760+
let len = self.len() - rem;
761+
ExactChunks { v: &self[..len], chunk_size: chunk_size}
762+
}
763+
764764
/// Returns an iterator over `chunk_size` elements of the slice at a time.
765765
/// The chunks are mutable slices, and do not overlap. If `chunk_size` does
766766
/// not divide the length of the slice, then the last up to `chunk_size-1`

0 commit comments

Comments
 (0)