@@ -328,6 +328,8 @@ pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend};
328328pub use self :: traits:: { ExactSizeIterator , Sum , Product } ;
329329#[ unstable( feature = "fused" , issue = "35602" ) ]
330330pub use self :: traits:: FusedIterator ;
331+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
332+ pub use self :: traits:: TrustedLen ;
331333
332334mod iterator;
333335mod range;
@@ -372,6 +374,10 @@ impl<I> ExactSizeIterator for Rev<I>
372374impl < I > FusedIterator for Rev < I >
373375 where I : FusedIterator + DoubleEndedIterator { }
374376
377+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
378+ unsafe impl < I > TrustedLen for Rev < I >
379+ where I : TrustedLen + DoubleEndedIterator { }
380+
375381/// An iterator that clones the elements of an underlying iterator.
376382///
377383/// 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>
432438 fn may_have_side_effect ( ) -> bool { true }
433439}
434440
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+
435447/// An iterator that repeats endlessly.
436448///
437449/// This `struct` is created by the [`cycle()`] method on [`Iterator`]. See its
@@ -642,6 +654,11 @@ impl<A, B> FusedIterator for Chain<A, B>
642654 B : FusedIterator < Item =A :: Item > ,
643655{ }
644656
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+
645662/// An iterator that iterates two other iterators simultaneously.
646663///
647664/// 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>
859876impl < A , B > FusedIterator for Zip < A , B >
860877 where A : FusedIterator , B : FusedIterator , { }
861878
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+
862884/// An iterator that maps the values of `iter` with `f`.
863885///
864886/// 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>
959981impl < B , I : FusedIterator , F > FusedIterator for Map < I , F >
960982 where F : FnMut ( I :: Item ) -> B { }
961983
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+
962989#[ doc( hidden) ]
963990unsafe impl < B , I , F > TrustedRandomAccess for Map < I , F >
964991 where I : TrustedRandomAccess ,
@@ -1195,6 +1222,12 @@ unsafe impl<I> TrustedRandomAccess for Enumerate<I>
11951222#[ unstable( feature = "fused" , issue = "35602" ) ]
11961223impl < I > FusedIterator for Enumerate < I > where I : FusedIterator { }
11971224
1225+ #[ unstable( feature = "trusted_len" , issue = "0" ) ]
1226+ unsafe impl < I > TrustedLen for Enumerate < I >
1227+ where I : TrustedLen ,
1228+ { }
1229+
1230+
11981231/// An iterator with a `peek()` that returns an optional reference to the next
11991232/// element.
12001233///
0 commit comments