Skip to content

Commit 6a0f45b

Browse files
authored
Rollup merge of rust-lang#54537 - sdroege:chunks-exact, r=alexcrichton
Rename slice::exact_chunks() to slice::chunks_exact() See rust-lang#47115 (comment) and rust-lang#47115 (comment)
2 parents 49e0049 + 068c92b commit 6a0f45b

File tree

7 files changed

+101
-101
lines changed

7 files changed

+101
-101
lines changed

src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
#![feature(unsize)]
117117
#![feature(allocator_internals)]
118118
#![feature(on_unimplemented)]
119-
#![feature(exact_chunks)]
119+
#![feature(chunks_exact)]
120120
#![feature(rustc_const_unstable)]
121121
#![feature(const_vec_new)]
122122
#![feature(slice_partition_dedup)]

src/liballoc/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ pub use core::slice::{from_raw_parts, from_raw_parts_mut};
123123
pub use core::slice::{from_ref, from_mut};
124124
#[stable(feature = "slice_get_slice", since = "1.28.0")]
125125
pub use core::slice::SliceIndex;
126-
#[unstable(feature = "exact_chunks", issue = "47115")]
127-
pub use core::slice::{ExactChunks, ExactChunksMut};
126+
#[unstable(feature = "chunks_exact", issue = "47115")]
127+
pub use core::slice::{ChunksExact, ChunksExactMut};
128128

129129
////////////////////////////////////////////////////////////////////////////////
130130
// Basic slice extension methods

src/liballoc/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![feature(str_escape)]
2121
#![feature(try_reserve)]
2222
#![feature(unboxed_closures)]
23-
#![feature(exact_chunks)]
23+
#![feature(chunks_exact)]
2424
#![feature(repeat_generic_slice)]
2525

2626
extern crate alloc_system;

src/liballoc/tests/slice.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -975,27 +975,27 @@ fn test_chunksator_0() {
975975
}
976976

977977
#[test]
978-
fn test_exact_chunksator() {
978+
fn test_chunks_exactator() {
979979
let v = &[1, 2, 3, 4, 5];
980980

981-
assert_eq!(v.exact_chunks(2).len(), 2);
981+
assert_eq!(v.chunks_exact(2).len(), 2);
982982

983983
let chunks: &[&[_]] = &[&[1, 2], &[3, 4]];
984-
assert_eq!(v.exact_chunks(2).collect::<Vec<_>>(), chunks);
984+
assert_eq!(v.chunks_exact(2).collect::<Vec<_>>(), chunks);
985985
let chunks: &[&[_]] = &[&[1, 2, 3]];
986-
assert_eq!(v.exact_chunks(3).collect::<Vec<_>>(), chunks);
986+
assert_eq!(v.chunks_exact(3).collect::<Vec<_>>(), chunks);
987987
let chunks: &[&[_]] = &[];
988-
assert_eq!(v.exact_chunks(6).collect::<Vec<_>>(), chunks);
988+
assert_eq!(v.chunks_exact(6).collect::<Vec<_>>(), chunks);
989989

990990
let chunks: &[&[_]] = &[&[3, 4], &[1, 2]];
991-
assert_eq!(v.exact_chunks(2).rev().collect::<Vec<_>>(), chunks);
991+
assert_eq!(v.chunks_exact(2).rev().collect::<Vec<_>>(), chunks);
992992
}
993993

994994
#[test]
995995
#[should_panic]
996-
fn test_exact_chunksator_0() {
996+
fn test_chunks_exactator_0() {
997997
let v = &[1, 2, 3, 4];
998-
let _it = v.exact_chunks(0);
998+
let _it = v.chunks_exact(0);
999999
}
10001000

10011001
#[test]
@@ -1235,10 +1235,10 @@ fn test_mut_chunks_0() {
12351235
}
12361236

12371237
#[test]
1238-
fn test_mut_exact_chunks() {
1238+
fn test_mut_chunks_exact() {
12391239
let mut v = [0, 1, 2, 3, 4, 5, 6];
1240-
assert_eq!(v.exact_chunks_mut(2).len(), 3);
1241-
for (i, chunk) in v.exact_chunks_mut(3).enumerate() {
1240+
assert_eq!(v.chunks_exact_mut(2).len(), 3);
1241+
for (i, chunk) in v.chunks_exact_mut(3).enumerate() {
12421242
for x in chunk {
12431243
*x = i as u8;
12441244
}
@@ -1248,9 +1248,9 @@ fn test_mut_exact_chunks() {
12481248
}
12491249

12501250
#[test]
1251-
fn test_mut_exact_chunks_rev() {
1251+
fn test_mut_chunks_exact_rev() {
12521252
let mut v = [0, 1, 2, 3, 4, 5, 6];
1253-
for (i, chunk) in v.exact_chunks_mut(3).rev().enumerate() {
1253+
for (i, chunk) in v.chunks_exact_mut(3).rev().enumerate() {
12541254
for x in chunk {
12551255
*x = i as u8;
12561256
}
@@ -1261,9 +1261,9 @@ fn test_mut_exact_chunks_rev() {
12611261

12621262
#[test]
12631263
#[should_panic]
1264-
fn test_mut_exact_chunks_0() {
1264+
fn test_mut_chunks_exact_0() {
12651265
let mut v = [1, 2, 3, 4];
1266-
let _it = v.exact_chunks_mut(0);
1266+
let _it = v.chunks_exact_mut(0);
12671267
}
12681268

12691269
#[test]

src/libcore/slice/mod.rs

+52-52
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ impl<T> [T] {
624624
/// not divide the length of the slice, then the last chunk will
625625
/// not have length `chunk_size`.
626626
///
627-
/// See [`exact_chunks`] for a variant of this iterator that returns chunks
627+
/// See [`chunks_exact`] for a variant of this iterator that returns chunks
628628
/// of always exactly `chunk_size` elements.
629629
///
630630
/// # Panics
@@ -642,7 +642,7 @@ impl<T> [T] {
642642
/// assert!(iter.next().is_none());
643643
/// ```
644644
///
645-
/// [`exact_chunks`]: #method.exact_chunks
645+
/// [`chunks_exact`]: #method.chunks_exact
646646
#[stable(feature = "rust1", since = "1.0.0")]
647647
#[inline]
648648
pub fn chunks(&self, chunk_size: usize) -> Chunks<T> {
@@ -655,7 +655,7 @@ impl<T> [T] {
655655
/// not divide the length of the slice, then the last chunk will not
656656
/// have length `chunk_size`.
657657
///
658-
/// See [`exact_chunks_mut`] for a variant of this iterator that returns chunks
658+
/// See [`chunks_exact_mut`] for a variant of this iterator that returns chunks
659659
/// of always exactly `chunk_size` elements.
660660
///
661661
/// # Panics
@@ -677,7 +677,7 @@ impl<T> [T] {
677677
/// assert_eq!(v, &[1, 1, 2, 2, 3]);
678678
/// ```
679679
///
680-
/// [`exact_chunks_mut`]: #method.exact_chunks_mut
680+
/// [`chunks_exact_mut`]: #method.chunks_exact_mut
681681
#[stable(feature = "rust1", since = "1.0.0")]
682682
#[inline]
683683
pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<T> {
@@ -702,24 +702,24 @@ impl<T> [T] {
702702
/// # Examples
703703
///
704704
/// ```
705-
/// #![feature(exact_chunks)]
705+
/// #![feature(chunks_exact)]
706706
///
707707
/// let slice = ['l', 'o', 'r', 'e', 'm'];
708-
/// let mut iter = slice.exact_chunks(2);
708+
/// let mut iter = slice.chunks_exact(2);
709709
/// assert_eq!(iter.next().unwrap(), &['l', 'o']);
710710
/// assert_eq!(iter.next().unwrap(), &['r', 'e']);
711711
/// assert!(iter.next().is_none());
712712
/// ```
713713
///
714714
/// [`chunks`]: #method.chunks
715-
#[unstable(feature = "exact_chunks", issue = "47115")]
715+
#[unstable(feature = "chunks_exact", issue = "47115")]
716716
#[inline]
717-
pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
717+
pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<T> {
718718
assert!(chunk_size != 0);
719719
let rem = self.len() % chunk_size;
720720
let len = self.len() - rem;
721721
let (fst, snd) = self.split_at(len);
722-
ExactChunks { v: fst, rem: snd, chunk_size }
722+
ChunksExact { v: fst, rem: snd, chunk_size }
723723
}
724724

725725
/// Returns an iterator over `chunk_size` elements of the slice at a time.
@@ -739,12 +739,12 @@ impl<T> [T] {
739739
/// # Examples
740740
///
741741
/// ```
742-
/// #![feature(exact_chunks)]
742+
/// #![feature(chunks_exact)]
743743
///
744744
/// let v = &mut [0, 0, 0, 0, 0];
745745
/// let mut count = 1;
746746
///
747-
/// for chunk in v.exact_chunks_mut(2) {
747+
/// for chunk in v.chunks_exact_mut(2) {
748748
/// for elem in chunk.iter_mut() {
749749
/// *elem += count;
750750
/// }
@@ -754,14 +754,14 @@ impl<T> [T] {
754754
/// ```
755755
///
756756
/// [`chunks_mut`]: #method.chunks_mut
757-
#[unstable(feature = "exact_chunks", issue = "47115")]
757+
#[unstable(feature = "chunks_exact", issue = "47115")]
758758
#[inline]
759-
pub fn exact_chunks_mut(&mut self, chunk_size: usize) -> ExactChunksMut<T> {
759+
pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<T> {
760760
assert!(chunk_size != 0);
761761
let rem = self.len() % chunk_size;
762762
let len = self.len() - rem;
763763
let (fst, snd) = self.split_at_mut(len);
764-
ExactChunksMut { v: fst, rem: snd, chunk_size }
764+
ChunksExactMut { v: fst, rem: snd, chunk_size }
765765
}
766766

767767
/// Divides one slice into two at an index.
@@ -3829,21 +3829,21 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> {
38293829
/// up to `chunk_size-1` elements will be omitted but can be retrieved from
38303830
/// the [`remainder`] function from the iterator.
38313831
///
3832-
/// This struct is created by the [`exact_chunks`] method on [slices].
3832+
/// This struct is created by the [`chunks_exact`] method on [slices].
38333833
///
3834-
/// [`exact_chunks`]: ../../std/primitive.slice.html#method.exact_chunks
3835-
/// [`remainder`]: ../../std/slice/struct.ExactChunks.html#method.remainder
3834+
/// [`chunks_exact`]: ../../std/primitive.slice.html#method.chunks_exact
3835+
/// [`remainder`]: ../../std/slice/struct.ChunksExact.html#method.remainder
38363836
/// [slices]: ../../std/primitive.slice.html
38373837
#[derive(Debug)]
3838-
#[unstable(feature = "exact_chunks", issue = "47115")]
3839-
pub struct ExactChunks<'a, T:'a> {
3838+
#[unstable(feature = "chunks_exact", issue = "47115")]
3839+
pub struct ChunksExact<'a, T:'a> {
38403840
v: &'a [T],
38413841
rem: &'a [T],
38423842
chunk_size: usize
38433843
}
38443844

3845-
#[unstable(feature = "exact_chunks", issue = "47115")]
3846-
impl<'a, T> ExactChunks<'a, T> {
3845+
#[unstable(feature = "chunks_exact", issue = "47115")]
3846+
impl<'a, T> ChunksExact<'a, T> {
38473847
/// Return the remainder of the original slice that is not going to be
38483848
/// returned by the iterator. The returned slice has at most `chunk_size-1`
38493849
/// elements.
@@ -3853,19 +3853,19 @@ impl<'a, T> ExactChunks<'a, T> {
38533853
}
38543854

38553855
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
3856-
#[unstable(feature = "exact_chunks", issue = "47115")]
3857-
impl<'a, T> Clone for ExactChunks<'a, T> {
3858-
fn clone(&self) -> ExactChunks<'a, T> {
3859-
ExactChunks {
3856+
#[unstable(feature = "chunks_exact", issue = "47115")]
3857+
impl<'a, T> Clone for ChunksExact<'a, T> {
3858+
fn clone(&self) -> ChunksExact<'a, T> {
3859+
ChunksExact {
38603860
v: self.v,
38613861
rem: self.rem,
38623862
chunk_size: self.chunk_size,
38633863
}
38643864
}
38653865
}
38663866

3867-
#[unstable(feature = "exact_chunks", issue = "47115")]
3868-
impl<'a, T> Iterator for ExactChunks<'a, T> {
3867+
#[unstable(feature = "chunks_exact", issue = "47115")]
3868+
impl<'a, T> Iterator for ChunksExact<'a, T> {
38693869
type Item = &'a [T];
38703870

38713871
#[inline]
@@ -3909,8 +3909,8 @@ impl<'a, T> Iterator for ExactChunks<'a, T> {
39093909
}
39103910
}
39113911

3912-
#[unstable(feature = "exact_chunks", issue = "47115")]
3913-
impl<'a, T> DoubleEndedIterator for ExactChunks<'a, T> {
3912+
#[unstable(feature = "chunks_exact", issue = "47115")]
3913+
impl<'a, T> DoubleEndedIterator for ChunksExact<'a, T> {
39143914
#[inline]
39153915
fn next_back(&mut self) -> Option<&'a [T]> {
39163916
if self.v.len() < self.chunk_size {
@@ -3923,21 +3923,21 @@ impl<'a, T> DoubleEndedIterator for ExactChunks<'a, T> {
39233923
}
39243924
}
39253925

3926-
#[unstable(feature = "exact_chunks", issue = "47115")]
3927-
impl<'a, T> ExactSizeIterator for ExactChunks<'a, T> {
3926+
#[unstable(feature = "chunks_exact", issue = "47115")]
3927+
impl<'a, T> ExactSizeIterator for ChunksExact<'a, T> {
39283928
fn is_empty(&self) -> bool {
39293929
self.v.is_empty()
39303930
}
39313931
}
39323932

39333933
#[unstable(feature = "trusted_len", issue = "37572")]
3934-
unsafe impl<'a, T> TrustedLen for ExactChunks<'a, T> {}
3934+
unsafe impl<'a, T> TrustedLen for ChunksExact<'a, T> {}
39353935

3936-
#[unstable(feature = "exact_chunks", issue = "47115")]
3937-
impl<'a, T> FusedIterator for ExactChunks<'a, T> {}
3936+
#[unstable(feature = "chunks_exact", issue = "47115")]
3937+
impl<'a, T> FusedIterator for ChunksExact<'a, T> {}
39383938

39393939
#[doc(hidden)]
3940-
unsafe impl<'a, T> TrustedRandomAccess for ExactChunks<'a, T> {
3940+
unsafe impl<'a, T> TrustedRandomAccess for ChunksExact<'a, T> {
39413941
unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] {
39423942
let start = i * self.chunk_size;
39433943
from_raw_parts(self.v.as_ptr().add(start), self.chunk_size)
@@ -3952,21 +3952,21 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunks<'a, T> {
39523952
/// `chunk_size-1` elements will be omitted but can be retrieved from the
39533953
/// [`into_remainder`] function from the iterator.
39543954
///
3955-
/// This struct is created by the [`exact_chunks_mut`] method on [slices].
3955+
/// This struct is created by the [`chunks_exact_mut`] method on [slices].
39563956
///
3957-
/// [`exact_chunks_mut`]: ../../std/primitive.slice.html#method.exact_chunks_mut
3958-
/// [`into_remainder`]: ../../std/slice/struct.ExactChunksMut.html#method.into_remainder
3957+
/// [`chunks_exact_mut`]: ../../std/primitive.slice.html#method.chunks_exact_mut
3958+
/// [`into_remainder`]: ../../std/slice/struct.ChunksExactMut.html#method.into_remainder
39593959
/// [slices]: ../../std/primitive.slice.html
39603960
#[derive(Debug)]
3961-
#[unstable(feature = "exact_chunks", issue = "47115")]
3962-
pub struct ExactChunksMut<'a, T:'a> {
3961+
#[unstable(feature = "chunks_exact", issue = "47115")]
3962+
pub struct ChunksExactMut<'a, T:'a> {
39633963
v: &'a mut [T],
39643964
rem: &'a mut [T],
39653965
chunk_size: usize
39663966
}
39673967

3968-
#[unstable(feature = "exact_chunks", issue = "47115")]
3969-
impl<'a, T> ExactChunksMut<'a, T> {
3968+
#[unstable(feature = "chunks_exact", issue = "47115")]
3969+
impl<'a, T> ChunksExactMut<'a, T> {
39703970
/// Return the remainder of the original slice that is not going to be
39713971
/// returned by the iterator. The returned slice has at most `chunk_size-1`
39723972
/// elements.
@@ -3975,8 +3975,8 @@ impl<'a, T> ExactChunksMut<'a, T> {
39753975
}
39763976
}
39773977

3978-
#[unstable(feature = "exact_chunks", issue = "47115")]
3979-
impl<'a, T> Iterator for ExactChunksMut<'a, T> {
3978+
#[unstable(feature = "chunks_exact", issue = "47115")]
3979+
impl<'a, T> Iterator for ChunksExactMut<'a, T> {
39803980
type Item = &'a mut [T];
39813981

39823982
#[inline]
@@ -4022,8 +4022,8 @@ impl<'a, T> Iterator for ExactChunksMut<'a, T> {
40224022
}
40234023
}
40244024

4025-
#[unstable(feature = "exact_chunks", issue = "47115")]
4026-
impl<'a, T> DoubleEndedIterator for ExactChunksMut<'a, T> {
4025+
#[unstable(feature = "chunks_exact", issue = "47115")]
4026+
impl<'a, T> DoubleEndedIterator for ChunksExactMut<'a, T> {
40274027
#[inline]
40284028
fn next_back(&mut self) -> Option<&'a mut [T]> {
40294029
if self.v.len() < self.chunk_size {
@@ -4038,21 +4038,21 @@ impl<'a, T> DoubleEndedIterator for ExactChunksMut<'a, T> {
40384038
}
40394039
}
40404040

4041-
#[unstable(feature = "exact_chunks", issue = "47115")]
4042-
impl<'a, T> ExactSizeIterator for ExactChunksMut<'a, T> {
4041+
#[unstable(feature = "chunks_exact", issue = "47115")]
4042+
impl<'a, T> ExactSizeIterator for ChunksExactMut<'a, T> {
40434043
fn is_empty(&self) -> bool {
40444044
self.v.is_empty()
40454045
}
40464046
}
40474047

40484048
#[unstable(feature = "trusted_len", issue = "37572")]
4049-
unsafe impl<'a, T> TrustedLen for ExactChunksMut<'a, T> {}
4049+
unsafe impl<'a, T> TrustedLen for ChunksExactMut<'a, T> {}
40504050

4051-
#[unstable(feature = "exact_chunks", issue = "47115")]
4052-
impl<'a, T> FusedIterator for ExactChunksMut<'a, T> {}
4051+
#[unstable(feature = "chunks_exact", issue = "47115")]
4052+
impl<'a, T> FusedIterator for ChunksExactMut<'a, T> {}
40534053

40544054
#[doc(hidden)]
4055-
unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
4055+
unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> {
40564056
unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut [T] {
40574057
let start = i * self.chunk_size;
40584058
from_raw_parts_mut(self.v.as_mut_ptr().add(start), self.chunk_size)

src/libcore/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#![feature(trusted_len)]
3434
#![feature(try_from)]
3535
#![feature(try_trait)]
36-
#![feature(exact_chunks)]
36+
#![feature(chunks_exact)]
3737
#![feature(align_offset)]
3838
#![feature(reverse_bits)]
3939
#![feature(inner_deref)]

0 commit comments

Comments
 (0)