/// This error is returned by [`try_collect_array`](super::CollectArray::try_collect_array) #[derive(Clone, Copy, Hash)] pub struct Error { /// Error returned by [next](Iterator::next)()?.error (`()` if [`None`]). pub error: Option, /// Point of error. pub at: usize, } impl PartialEq> for Error { fn eq(&self, other: &Error) -> bool { (self.error == other.error) & (self.at == other.at) } } impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match (&self.error, &self.at) { (Some(x), at) => write!(f, "{x} @ {at} of {N}"), (None, at) => write!( f, "couldnt fill array of length {N}, only had {at} elements.", ), } } } impl core::fmt::Debug for Error { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match (&self.error, &self.at) { (Some(x), at) => write!(f, "{x:?} @ {at} of {N}"), (None, at) => write!(f, "Size(wanted {N}, had {at})"), } } } impl core::error::Error for Error { fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { Some(self.error.as_ref()?) } }