itertools/
all_equal_value_err.rs1#[cfg(doc)]
2use crate::Itertools;
3#[cfg(feature = "use_std")]
4use std::error::Error;
5use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
6
7#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
9pub struct AllEqualValueError<Item>(pub Option<[Item; 2]>);
10
11impl<Item> Display for AllEqualValueError<Item> {
12 fn fmt(&self, f: &mut Formatter) -> FmtResult {
13 match self.0 {
14 None => {
15 write!(
16 f,
17 "got zero elements when all elements were expected to be equal"
18 )
19 }
20 Some([_, _]) => {
21 write!(
22 f,
23 "got different elements when all elements were expected to be equal"
24 )
25 }
26 }
27 }
28}
29
30#[cfg(feature = "use_std")]
31impl<Item> Error for AllEqualValueError<Item> where Item: Debug {}