@@ -96,6 +96,7 @@ pub mod structs {
96
96
FilterOk , Interleave , InterleaveShortest , MapInto , MapOk , Positions , Product , PutBack ,
97
97
TakeWhileRef , TupleCombinations , Update , WhileSome ,
98
98
} ;
99
+ pub use crate :: all_equal_value_err:: AllEqualValueError ;
99
100
#[ cfg( feature = "use_alloc" ) ]
100
101
pub use crate :: combinations:: { ArrayCombinations , Combinations } ;
101
102
#[ cfg( feature = "use_alloc" ) ]
@@ -177,6 +178,7 @@ pub use crate::either_or_both::EitherOrBoth;
177
178
pub mod free;
178
179
#[ doc( inline) ]
179
180
pub use crate :: free:: * ;
181
+ mod all_equal_value_err;
180
182
#[ cfg( feature = "use_alloc" ) ]
181
183
mod combinations;
182
184
#[ cfg( feature = "use_alloc" ) ]
@@ -2232,27 +2234,27 @@ pub trait Itertools: Iterator {
2232
2234
/// two non-equal elements found.
2233
2235
///
2234
2236
/// ```
2235
- /// use itertools::Itertools;
2237
+ /// use itertools::{ Itertools, AllEqualValueError} ;
2236
2238
///
2237
2239
/// let data = vec![1, 1, 1, 2, 2, 3, 3, 3, 4, 5, 5];
2238
- /// assert_eq!(data.iter().all_equal_value(), Err(Some(( &1, &2))));
2240
+ /// assert_eq!(data.iter().all_equal_value(), Err(AllEqualValueError( Some([ &1, &2] ))));
2239
2241
/// assert_eq!(data[0..3].iter().all_equal_value(), Ok(&1));
2240
2242
/// assert_eq!(data[3..5].iter().all_equal_value(), Ok(&2));
2241
2243
/// assert_eq!(data[5..8].iter().all_equal_value(), Ok(&3));
2242
2244
///
2243
2245
/// let data : Option<usize> = None;
2244
- /// assert_eq!(data.into_iter().all_equal_value(), Err(None));
2246
+ /// assert_eq!(data.into_iter().all_equal_value(), Err(AllEqualValueError( None) ));
2245
2247
/// ```
2246
2248
#[ allow( clippy:: type_complexity) ]
2247
- fn all_equal_value ( & mut self ) -> Result < Self :: Item , Option < ( Self :: Item , Self :: Item ) > >
2249
+ fn all_equal_value ( & mut self ) -> Result < Self :: Item , AllEqualValueError < Self :: Item > >
2248
2250
where
2249
2251
Self : Sized ,
2250
2252
Self :: Item : PartialEq ,
2251
2253
{
2252
- let first = self . next ( ) . ok_or ( None ) ?;
2254
+ let first = self . next ( ) . ok_or ( AllEqualValueError ( None ) ) ?;
2253
2255
let other = self . find ( |x| x != & first) ;
2254
2256
if let Some ( other) = other {
2255
- Err ( Some ( ( first, other) ) )
2257
+ Err ( AllEqualValueError ( Some ( [ first, other] ) ) )
2256
2258
} else {
2257
2259
Ok ( first)
2258
2260
}
0 commit comments