@@ -96,6 +96,7 @@ pub mod structs {
9696 FilterOk , Interleave , InterleaveShortest , MapInto , MapOk , Positions , Product , PutBack ,
9797 TakeWhileRef , TupleCombinations , Update , WhileSome ,
9898 } ;
99+ pub use crate :: all_equal_value_err:: AllEqualValueError ;
99100 #[ cfg( feature = "use_alloc" ) ]
100101 pub use crate :: combinations:: { ArrayCombinations , Combinations } ;
101102 #[ cfg( feature = "use_alloc" ) ]
@@ -177,6 +178,7 @@ pub use crate::either_or_both::EitherOrBoth;
177178pub mod free;
178179#[ doc( inline) ]
179180pub use crate :: free:: * ;
181+ mod all_equal_value_err;
180182#[ cfg( feature = "use_alloc" ) ]
181183mod combinations;
182184#[ cfg( feature = "use_alloc" ) ]
@@ -2232,27 +2234,27 @@ pub trait Itertools: Iterator {
22322234 /// two non-equal elements found.
22332235 ///
22342236 /// ```
2235- /// use itertools::Itertools;
2237+ /// use itertools::{ Itertools, AllEqualValueError} ;
22362238 ///
22372239 /// 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] ))));
22392241 /// assert_eq!(data[0..3].iter().all_equal_value(), Ok(&1));
22402242 /// assert_eq!(data[3..5].iter().all_equal_value(), Ok(&2));
22412243 /// assert_eq!(data[5..8].iter().all_equal_value(), Ok(&3));
22422244 ///
22432245 /// 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) ));
22452247 /// ```
22462248 #[ 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 > >
22482250 where
22492251 Self : Sized ,
22502252 Self :: Item : PartialEq ,
22512253 {
2252- let first = self . next ( ) . ok_or ( None ) ?;
2254+ let first = self . next ( ) . ok_or ( AllEqualValueError ( None ) ) ?;
22532255 let other = self . find ( |x| x != & first) ;
22542256 if let Some ( other) = other {
2255- Err ( Some ( ( first, other) ) )
2257+ Err ( AllEqualValueError ( Some ( [ first, other] ) ) )
22562258 } else {
22572259 Ok ( first)
22582260 }
0 commit comments