Skip to content

Commit a1809d5

Browse files
committed
Implement TrustedLen for Take<Repeat> and Take<RangeFrom>
1 parent 3986539 commit a1809d5

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/libcore/iter/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,9 @@ impl<I> ExactSizeIterator for Take<I> where I: ExactSizeIterator {}
23222322
#[unstable(feature = "fused", issue = "35602")]
23232323
impl<I> FusedIterator for Take<I> where I: FusedIterator {}
23242324

2325+
#[unstable(feature = "trusted_len", issue = "37572")]
2326+
unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}
2327+
23252328
/// An iterator to maintain state while iterating another iterator.
23262329
///
23272330
/// This `struct` is created by the [`scan`] method on [`Iterator`]. See its

src/libcore/iter/range.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ impl<A: Step> Iterator for ops::RangeFrom<A> {
325325
#[unstable(feature = "fused", issue = "35602")]
326326
impl<A: Step> FusedIterator for ops::RangeFrom<A> {}
327327

328+
#[unstable(feature = "trusted_len", issue = "37572")]
329+
unsafe impl<A: Step> TrustedLen for ops::RangeFrom<A> {}
330+
328331
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
329332
impl<A: Step> Iterator for ops::RangeInclusive<A> {
330333
type Item = A;

src/libcore/iter/sources.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ impl<A: Clone> DoubleEndedIterator for Repeat<A> {
4444
#[unstable(feature = "fused", issue = "35602")]
4545
impl<A: Clone> FusedIterator for Repeat<A> {}
4646

47+
#[unstable(feature = "trusted_len", issue = "37572")]
48+
unsafe impl<A: Clone> TrustedLen for Repeat<A> {}
49+
4750
/// Creates a new iterator that endlessly repeats a single element.
4851
///
4952
/// The `repeat()` function repeats a single value over and over and over and

0 commit comments

Comments
 (0)