@@ -97,6 +97,7 @@ pub mod structs {
97
97
FilterOk , Interleave , InterleaveShortest , MapInto , MapOk , Positions , Product , PutBack ,
98
98
TakeWhileRef , TupleCombinations , Update , WhileSome ,
99
99
} ;
100
+ pub use crate :: all_equal_value_err:: AllEqualValueError ;
100
101
#[ cfg( feature = "use_alloc" ) ]
101
102
pub use crate :: combinations:: { ArrayCombinations , Combinations } ;
102
103
#[ cfg( feature = "use_alloc" ) ]
@@ -180,6 +181,7 @@ pub use crate::either_or_both::EitherOrBoth;
180
181
pub mod free;
181
182
#[ doc( inline) ]
182
183
pub use crate :: free:: * ;
184
+ mod all_equal_value_err;
183
185
#[ cfg( feature = "use_alloc" ) ]
184
186
mod combinations;
185
187
#[ cfg( feature = "use_alloc" ) ]
@@ -2268,27 +2270,27 @@ pub trait Itertools: Iterator {
2268
2270
/// two non-equal elements found.
2269
2271
///
2270
2272
/// ```
2271
- /// use itertools::Itertools;
2273
+ /// use itertools::{ Itertools, AllEqualValueError} ;
2272
2274
///
2273
2275
/// let data = vec![1, 1, 1, 2, 2, 3, 3, 3, 4, 5, 5];
2274
- /// assert_eq!(data.iter().all_equal_value(), Err(Some(( &1, &2))));
2276
+ /// assert_eq!(data.iter().all_equal_value(), Err(AllEqualValueError( Some([ &1, &2] ))));
2275
2277
/// assert_eq!(data[0..3].iter().all_equal_value(), Ok(&1));
2276
2278
/// assert_eq!(data[3..5].iter().all_equal_value(), Ok(&2));
2277
2279
/// assert_eq!(data[5..8].iter().all_equal_value(), Ok(&3));
2278
2280
///
2279
2281
/// let data: Option<usize> = None;
2280
- /// assert_eq!(data.into_iter().all_equal_value(), Err(None));
2282
+ /// assert_eq!(data.into_iter().all_equal_value(), Err(AllEqualValueError( None) ));
2281
2283
/// ```
2282
2284
#[ allow( clippy:: type_complexity) ]
2283
- fn all_equal_value ( & mut self ) -> Result < Self :: Item , Option < ( Self :: Item , Self :: Item ) > >
2285
+ fn all_equal_value ( & mut self ) -> Result < Self :: Item , AllEqualValueError < Self :: Item > >
2284
2286
where
2285
2287
Self : Sized ,
2286
2288
Self :: Item : PartialEq ,
2287
2289
{
2288
- let first = self . next ( ) . ok_or ( None ) ?;
2290
+ let first = self . next ( ) . ok_or ( AllEqualValueError ( None ) ) ?;
2289
2291
let other = self . find ( |x| x != & first) ;
2290
2292
if let Some ( other) = other {
2291
- Err ( Some ( ( first, other) ) )
2293
+ Err ( AllEqualValueError ( Some ( [ first, other] ) ) )
2292
2294
} else {
2293
2295
Ok ( first)
2294
2296
}
0 commit comments