1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
use crate::float_diff_provider::FloatDiffProvider; use crate::Shoulda; use std::borrow::Cow; use std::fmt::Debug; use std::ops::Deref; impl<K> Shoulda for Option<K> where K: Shoulda, K: Debug, { fn test_eq<FloatDiff: FloatDiffProvider>(&self, other: &Self) -> bool { match (self, other) { (None, None) => true, (Some(a), Some(b)) => a.test_eq::<FloatDiff>(b), _ => false, } } } impl<L, K> Shoulda for Result<L, K> where L: Shoulda, L: Debug, K: Shoulda, K: Debug, { fn test_eq<FloatDiff: FloatDiffProvider>(&self, other: &Self) -> bool { match (self, other) { (Err(a), Err(b)) => a.test_eq::<FloatDiff>(b), (Ok(a), Ok(b)) => a.test_eq::<FloatDiff>(b), _ => false, } } } impl<K> Shoulda for Cow<'_, K> where K: Shoulda, K: Debug, K: ToOwned, <K as ToOwned>::Owned: Debug, K: ?Sized, { fn test_eq<FloatDiff: FloatDiffProvider>(&self, other: &Self) -> bool { self.deref().test_eq::<FloatDiff>(other.deref()) } } impl<T> Shoulda for Box<T> where T: Shoulda, T: ?Sized, { fn test_eq<FloatDiff: FloatDiffProvider>(&self, other: &Self) -> bool { self.deref().test_eq::<FloatDiff>(other.deref()) } }