Skip to content

Commit c3eff19

Browse files
Rollup merge of #51326 - sdroege:slice-iter-cleanup, r=dtolnay
Various minor slice iterator cleanups See individual commits
2 parents e7ae1b2 + 10cf7bb commit c3eff19

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

src/libcore/slice/mod.rs

+22-16
Original file line numberDiff line numberDiff line change
@@ -2541,6 +2541,12 @@ macro_rules! iterator {
25412541
accum
25422542
}
25432543
}
2544+
2545+
#[stable(feature = "fused", since = "1.26.0")]
2546+
impl<'a, T> FusedIterator for $name<'a, T> {}
2547+
2548+
#[unstable(feature = "trusted_len", issue = "37572")]
2549+
unsafe impl<'a, T> TrustedLen for $name<'a, T> {}
25442550
}
25452551
}
25462552

@@ -2667,12 +2673,6 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {
26672673
}
26682674
}
26692675

2670-
#[stable(feature = "fused", since = "1.26.0")]
2671-
impl<'a, T> FusedIterator for Iter<'a, T> {}
2672-
2673-
#[unstable(feature = "trusted_len", issue = "37572")]
2674-
unsafe impl<'a, T> TrustedLen for Iter<'a, T> {}
2675-
26762676
#[stable(feature = "rust1", since = "1.0.0")]
26772677
impl<'a, T> Clone for Iter<'a, T> {
26782678
fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } }
@@ -2734,9 +2734,7 @@ impl<'a, T> IterMut<'a, T> {
27342734
/// View the underlying data as a subslice of the original data.
27352735
///
27362736
/// To avoid creating `&mut` references that alias, this is forced
2737-
/// to consume the iterator. Consider using the `Slice` and
2738-
/// `SliceMut` implementations for obtaining slices with more
2739-
/// restricted lifetimes that do not consume the iterator.
2737+
/// to consume the iterator.
27402738
///
27412739
/// # Examples
27422740
///
@@ -2795,13 +2793,6 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {
27952793
}
27962794
}
27972795

2798-
#[stable(feature = "fused", since = "1.26.0")]
2799-
impl<'a, T> FusedIterator for IterMut<'a, T> {}
2800-
2801-
#[unstable(feature = "trusted_len", issue = "37572")]
2802-
unsafe impl<'a, T> TrustedLen for IterMut<'a, T> {}
2803-
2804-
28052796
// Return the number of elements of `T` from `start` to `end`.
28062797
// Return the arithmetic difference if `T` is zero size.
28072798
#[inline(always)]
@@ -3399,6 +3390,9 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> {
33993390
#[stable(feature = "rust1", since = "1.0.0")]
34003391
impl<'a, T> ExactSizeIterator for Windows<'a, T> {}
34013392

3393+
#[unstable(feature = "trusted_len", issue = "37572")]
3394+
unsafe impl<'a, T> TrustedLen for Windows<'a, T> {}
3395+
34023396
#[stable(feature = "fused", since = "1.26.0")]
34033397
impl<'a, T> FusedIterator for Windows<'a, T> {}
34043398

@@ -3518,6 +3512,9 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
35183512
#[stable(feature = "rust1", since = "1.0.0")]
35193513
impl<'a, T> ExactSizeIterator for Chunks<'a, T> {}
35203514

3515+
#[unstable(feature = "trusted_len", issue = "37572")]
3516+
unsafe impl<'a, T> TrustedLen for Chunks<'a, T> {}
3517+
35213518
#[stable(feature = "fused", since = "1.26.0")]
35223519
impl<'a, T> FusedIterator for Chunks<'a, T> {}
35233520

@@ -3634,6 +3631,9 @@ impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> {
36343631
#[stable(feature = "rust1", since = "1.0.0")]
36353632
impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {}
36363633

3634+
#[unstable(feature = "trusted_len", issue = "37572")]
3635+
unsafe impl<'a, T> TrustedLen for ChunksMut<'a, T> {}
3636+
36373637
#[stable(feature = "fused", since = "1.26.0")]
36383638
impl<'a, T> FusedIterator for ChunksMut<'a, T> {}
36393639

@@ -3744,6 +3744,9 @@ impl<'a, T> ExactSizeIterator for ExactChunks<'a, T> {
37443744
}
37453745
}
37463746

3747+
#[unstable(feature = "trusted_len", issue = "37572")]
3748+
unsafe impl<'a, T> TrustedLen for ExactChunks<'a, T> {}
3749+
37473750
#[unstable(feature = "exact_chunks", issue = "47115")]
37483751
impl<'a, T> FusedIterator for ExactChunks<'a, T> {}
37493752

@@ -3841,6 +3844,9 @@ impl<'a, T> ExactSizeIterator for ExactChunksMut<'a, T> {
38413844
}
38423845
}
38433846

3847+
#[unstable(feature = "trusted_len", issue = "37572")]
3848+
unsafe impl<'a, T> TrustedLen for ExactChunksMut<'a, T> {}
3849+
38443850
#[unstable(feature = "exact_chunks", issue = "47115")]
38453851
impl<'a, T> FusedIterator for ExactChunksMut<'a, T> {}
38463852

0 commit comments

Comments
 (0)