The assert_receiver_is_total_eq method is purely so that #[deriving] can enforce that all the contained types are TotalEq. It currently exists because the #[deriving] infrastructure makes it much much much easier to work with a method on a trait than with anything else.
Preferably #[deriving] would be refactored to allow creating a non trait function along the lines of
#[deriving(TotalEq)]
struct Foo<T> {
x: int,
y: T
}
// expands to
impl<T: TotalEq> TotalEq for Foo<T> {}
impl<T: TotalEq> Foo<T> {
#[allow(dead_code)]
fn assert_Foo_is_total_eq(&self) {
fn total_eq<T: TotalEq>(_: &T) {}
total_eq(&self.x);
total_eq(&self.y);
}
}
which would allow TotalEq to become just trait TotalEq: Eq {}.
(Placeholder issue for now.)
The
assert_receiver_is_total_eqmethod is purely so that#[deriving]can enforce that all the contained types areTotalEq. It currently exists because the#[deriving]infrastructure makes it much much much easier to work with a method on a trait than with anything else.Preferably
#[deriving]would be refactored to allow creating a non trait function along the lines ofwhich would allow
TotalEqto become justtrait TotalEq: Eq {}.(Placeholder issue for now.)