- Suppose we have:
impl T {
pub fn special_equal(&self, rhs: &T) -> bool;
}
-
Suppose we can NOT implement Eq (it needs to be reserved for another purpose)
-
Is there an idiomatic way to do special_equal on a
Vec<T>
? The less elegant solution is:
fn foo(lhs: &Vec<T>, rhs: &Vec<T> -> bool {
if lhs.len() != rhs.len() { return false; }
for i in 0..lhs.len() {
if !lhs[i].special_equal(rhs[i]) { return false; }
}
return true;
}
I am wondering if there is some builtin that can be used to do this.