@@ -5180,19 +5180,17 @@ pub trait Itertools: Iterator {
51805180 F : FnMut ( & Self :: Item , & Prefix :: Item ) -> bool ,
51815181 {
51825182 let mut prefix = prefix. into_iter ( ) ;
5183- while let Some ( wanted) = prefix. next ( ) {
5184- match self . next ( ) {
5185- Some ( got) if eq ( & got, & wanted) => continue ,
5186- got => {
5187- return Err ( StripPrefixError {
5188- iterator : self ,
5189- prefix,
5190- mismatch : ( got, wanted) ,
5191- } ) ;
5192- }
5193- }
5183+ match prefix. by_ref ( ) . try_for_each ( |wanted| match self . next ( ) {
5184+ Some ( got) if eq ( & got, & wanted) => Ok ( ( ) ) ,
5185+ got => Err ( ( got, wanted) ) ,
5186+ } ) {
5187+ Ok ( ( ) ) => Ok ( self ) ,
5188+ Err ( mismatch) => Err ( StripPrefixError {
5189+ iterator : self ,
5190+ prefix,
5191+ mismatch,
5192+ } ) ,
51945193 }
5195- Ok ( self )
51965194 }
51975195}
51985196
@@ -5202,7 +5200,7 @@ pub trait Itertools: Iterator {
52025200///
52035201/// All fields are public so callers can recover the partially-consumed
52045202/// iterators and the mismatched items.
5205- #[ derive( Debug , Clone , PartialEq , Eq ) ]
5203+ #[ derive( Debug , Clone ) ]
52065204pub struct StripPrefixError < I , Prefix : Iterator , T > {
52075205 /// The remainder of the original iterator, advanced past the matched
52085206 /// prefix items but stopped at the position of the mismatch.
0 commit comments