Trait deltae::eq::DeltaEq [−][src]
pub trait DeltaEq<D: Delta + Copy>: Delta + Copy { fn delta_eq<T: Tolerance>(
&self,
other: D,
method: DEMethod,
tolerance: T
) -> bool { ... } }
Expand description
Trait to determine whether two values are within a certain tolerance of DeltaE
. Types that
implement Into<LabValue
> implicitly implement Delta
. Types that implement Delta
and
Copy
may also implement DeltaEq for other types that also implement Delta
and Copy
.
use deltae::*; #[derive(Copy, Clone)] struct MyLab(f32, f32, f32); // Types that implement Into<Lab> implicitly implement the Delta trait impl From<MyLab> for LabValue { fn from(mylab: MyLab) -> LabValue { LabValue { l: mylab.0, a: mylab.1, b: mylab.2, } } } // Types that implement Delta and Copy may also implement DeltaEq for other types that also // implement Delta and Copy impl<D: Delta + Copy> DeltaEq<D> for MyLab {} let mylab = MyLab(89.73, 1.88, -6.96); let lab = LabValue::new(89.73, 1.88, -6.96).unwrap(); let de2000 = mylab.delta(lab, DEMethod::DE2000); assert!(mylab.delta_eq(&lab, DE1976, 0.0));