1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
pub trait Setoid { fn equals(&self, other: &Self) -> bool; } impl Setoid for Vec<i32> { fn equals(&self, other: &Self) -> bool { self.len() == other.len() } } impl Setoid for &str { fn equals(&self, other: &Self) -> bool { self.eq(other) } }