mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
rollup merge of #21053: apasel422/exact
This commit is contained in:
commit
2e9adab528
@ -2409,8 +2409,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chunksator() {
|
fn test_chunksator() {
|
||||||
|
use core::iter::ExactSizeIterator;
|
||||||
|
|
||||||
let v = &[1i,2,3,4,5];
|
let v = &[1i,2,3,4,5];
|
||||||
|
|
||||||
|
assert_eq!(v.chunks(2).len(), 3);
|
||||||
|
|
||||||
let chunks: &[&[int]] = &[&[1i,2], &[3,4], &[5]];
|
let chunks: &[&[int]] = &[&[1i,2], &[3,4], &[5]];
|
||||||
assert_eq!(v.chunks(2).collect::<Vec<&[int]>>(), chunks);
|
assert_eq!(v.chunks(2).collect::<Vec<&[int]>>(), chunks);
|
||||||
let chunks: &[&[int]] = &[&[1i,2,3], &[4,5]];
|
let chunks: &[&[int]] = &[&[1i,2,3], &[4,5]];
|
||||||
@ -2675,7 +2679,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mut_chunks() {
|
fn test_mut_chunks() {
|
||||||
|
use core::iter::ExactSizeIterator;
|
||||||
|
|
||||||
let mut v = [0u8, 1, 2, 3, 4, 5, 6];
|
let mut v = [0u8, 1, 2, 3, 4, 5, 6];
|
||||||
|
assert_eq!(v.chunks_mut(2).len(), 4);
|
||||||
for (i, chunk) in v.chunks_mut(3).enumerate() {
|
for (i, chunk) in v.chunks_mut(3).enumerate() {
|
||||||
for x in chunk.iter_mut() {
|
for x in chunk.iter_mut() {
|
||||||
*x = i as u8;
|
*x = i as u8;
|
||||||
|
@ -1269,6 +1269,9 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable]
|
||||||
|
impl<'a, T> ExactSizeIterator for Chunks<'a, T> {}
|
||||||
|
|
||||||
#[unstable = "trait is experimental"]
|
#[unstable = "trait is experimental"]
|
||||||
impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
|
impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1347,6 +1350,8 @@ impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable]
|
||||||
|
impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Free functions
|
// Free functions
|
||||||
|
Loading…
Reference in New Issue
Block a user