@@ -328,6 +328,8 @@ pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend};
328
328
pub use self :: traits:: { ExactSizeIterator , Sum , Product } ;
329
329
#[ unstable( feature = "fused" , issue = "35602" ) ]
330
330
pub use self :: traits:: FusedIterator ;
331
+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
332
+ pub use self :: traits:: TrustedLen ;
331
333
332
334
mod iterator;
333
335
mod range;
@@ -372,6 +374,10 @@ impl<I> ExactSizeIterator for Rev<I>
372
374
impl < I > FusedIterator for Rev < I >
373
375
where I : FusedIterator + DoubleEndedIterator { }
374
376
377
+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
378
+ unsafe impl < I > TrustedLen for Rev < I >
379
+ where I : TrustedLen + DoubleEndedIterator { }
380
+
375
381
/// An iterator that clones the elements of an underlying iterator.
376
382
///
377
383
/// This `struct` is created by the [`cloned()`] method on [`Iterator`]. See its
@@ -432,6 +438,12 @@ unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned<I>
432
438
fn may_have_side_effect ( ) -> bool { true }
433
439
}
434
440
441
+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
442
+ unsafe impl < ' a , I , T : ' a > TrustedLen for Cloned < I >
443
+ where I : TrustedLen < Item =& ' a T > ,
444
+ T : Clone
445
+ { }
446
+
435
447
/// An iterator that repeats endlessly.
436
448
///
437
449
/// This `struct` is created by the [`cycle()`] method on [`Iterator`]. See its
@@ -642,6 +654,11 @@ impl<A, B> FusedIterator for Chain<A, B>
642
654
B : FusedIterator < Item =A :: Item > ,
643
655
{ }
644
656
657
+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
658
+ unsafe impl < A , B > TrustedLen for Chain < A , B >
659
+ where A : TrustedLen , B : TrustedLen < Item =A :: Item > ,
660
+ { }
661
+
645
662
/// An iterator that iterates two other iterators simultaneously.
646
663
///
647
664
/// This `struct` is created by the [`zip()`] method on [`Iterator`]. See its
@@ -859,6 +876,11 @@ unsafe impl<A, B> TrustedRandomAccess for Zip<A, B>
859
876
impl < A , B > FusedIterator for Zip < A , B >
860
877
where A : FusedIterator , B : FusedIterator , { }
861
878
879
+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
880
+ unsafe impl < A , B > TrustedLen for Zip < A , B >
881
+ where A : TrustedLen , B : TrustedLen ,
882
+ { }
883
+
862
884
/// An iterator that maps the values of `iter` with `f`.
863
885
///
864
886
/// This `struct` is created by the [`map()`] method on [`Iterator`]. See its
@@ -959,6 +981,11 @@ impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F>
959
981
impl < B , I : FusedIterator , F > FusedIterator for Map < I , F >
960
982
where F : FnMut ( I :: Item ) -> B { }
961
983
984
+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
985
+ unsafe impl < B , I , F > TrustedLen for Map < I , F >
986
+ where I : TrustedLen ,
987
+ F : FnMut ( I :: Item ) -> B { }
988
+
962
989
#[ doc( hidden) ]
963
990
unsafe impl < B , I , F > TrustedRandomAccess for Map < I , F >
964
991
where I : TrustedRandomAccess ,
@@ -1195,6 +1222,12 @@ unsafe impl<I> TrustedRandomAccess for Enumerate<I>
1195
1222
#[ unstable( feature = "fused" , issue = "35602" ) ]
1196
1223
impl < I > FusedIterator for Enumerate < I > where I : FusedIterator { }
1197
1224
1225
+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
1226
+ unsafe impl < I > TrustedLen for Enumerate < I >
1227
+ where I : TrustedLen ,
1228
+ { }
1229
+
1230
+
1198
1231
/// An iterator with a `peek()` that returns an optional reference to the next
1199
1232
/// element.
1200
1233
///
0 commit comments