Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various minor slice iterator cleanups #51326

Merged
merged 3 commits into from
Jun 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,12 @@ macro_rules! iterator {
accum
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for $name<'a, T> {}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for $name<'a, T> {}
}
}

Expand Down Expand Up @@ -2639,12 +2645,6 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Iter<'a, T> {}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for Iter<'a, T> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } }
Expand Down Expand Up @@ -2706,9 +2706,7 @@ impl<'a, T> IterMut<'a, T> {
/// View the underlying data as a subslice of the original data.
///
/// To avoid creating `&mut` references that alias, this is forced
/// to consume the iterator. Consider using the `Slice` and
/// `SliceMut` implementations for obtaining slices with more
/// restricted lifetimes that do not consume the iterator.
/// to consume the iterator.
///
/// # Examples
///
Expand Down Expand Up @@ -2767,13 +2765,6 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for IterMut<'a, T> {}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for IterMut<'a, T> {}


// Return the number of elements of `T` from `start` to `end`.
// Return the arithmetic difference if `T` is zero size.
#[inline(always)]
Expand Down Expand Up @@ -3371,6 +3362,9 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Windows<'a, T> {}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for Windows<'a, T> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Windows<'a, T> {}

Expand Down Expand Up @@ -3490,6 +3484,9 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Chunks<'a, T> {}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for Chunks<'a, T> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for Chunks<'a, T> {}

Expand Down Expand Up @@ -3606,6 +3603,9 @@ impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for ChunksMut<'a, T> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for ChunksMut<'a, T> {}

Expand Down Expand Up @@ -3716,6 +3716,9 @@ impl<'a, T> ExactSizeIterator for ExactChunks<'a, T> {
}
}

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

#[unstable(feature = "exact_chunks", issue = "47115")]
impl<'a, T> FusedIterator for ExactChunks<'a, T> {}

Expand Down Expand Up @@ -3813,6 +3816,9 @@ impl<'a, T> ExactSizeIterator for ExactChunksMut<'a, T> {
}
}

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

#[unstable(feature = "exact_chunks", issue = "47115")]
impl<'a, T> FusedIterator for ExactChunksMut<'a, T> {}

Expand Down