macro_rules! eq_trait_object {
($trait:ident) => { ... };
}Expand description
Implement PartialEq and Eq for the objects of a trait having DynEq
as a supertrait, in all four Send/Sync combinations.
Takes a bare trait name: a generic trait would need the argument list threaded through, and tract has none needing this.
use tract_data::dyn_eq::DynEq;
trait Weigh: DynEq {}
tract_data::eq_trait_object!(Weigh);
impl Weigh for u8 {}
impl Weigh for u16 {}
let five: &dyn Weigh = &5u8;
assert!(five == &5u8 as &dyn Weigh);
assert!(five != &6u8 as &dyn Weigh);
// same value, other type: not equal
assert!(five != &5u16 as &dyn Weigh);