diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 988ec4c661f..cefa540b9a2 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -2409,8 +2409,12 @@ mod tests { #[test] fn test_chunksator() { + use core::iter::ExactSizeIterator; + let v = &[1i,2,3,4,5]; + assert_eq!(v.chunks(2).len(), 3); + let chunks: &[&[int]] = &[&[1i,2], &[3,4], &[5]]; assert_eq!(v.chunks(2).collect::>(), chunks); let chunks: &[&[int]] = &[&[1i,2,3], &[4,5]]; @@ -2675,7 +2679,10 @@ mod tests { #[test] fn test_mut_chunks() { + use core::iter::ExactSizeIterator; + 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 x in chunk.iter_mut() { *x = i as u8; diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 50cbb7a61dc..ae5dc1bffa6 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -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"] impl<'a, T> RandomAccessIterator for Chunks<'a, T> { #[inline] @@ -1347,6 +1350,8 @@ impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> { } } +#[stable] +impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {} // // Free functions