std: remove the equals method from TotalEq.

`TotalEq` is now just an assertion about the `Eq` impl of a
type (i.e. `==` is a total equality if a type implements `TotalEq`) so
the extra method is just confusing.

Also, a new method magically appeared as a hack to allow deriving to
assert that the contents of a struct/enum are also TotalEq, because the
deriving infrastructure makes it very hard to do anything but create a
trait method. (You didn't hear about this horrible work-around from me
:(.)
This commit is contained in:
Huon Wilson
2014-03-23 22:54:42 +11:00
parent 2ddb605654
commit f6db0ef946
23 changed files with 74 additions and 208 deletions

View File

@@ -75,12 +75,7 @@ macro_rules! tuple_impls {
}
#[cfg(not(test))]
impl<$($T:TotalEq),+> TotalEq for ($($T,)+) {
#[inline]
fn equals(&self, other: &($($T,)+)) -> bool {
$(self.$refN().equals(other.$refN()))&&+
}
}
impl<$($T:TotalEq),+> TotalEq for ($($T,)+) {}
#[cfg(not(test))]
impl<$($T:Ord + Eq),+> Ord for ($($T,)+) {
@@ -338,12 +333,6 @@ mod tests {
assert!(((1.0, 2.0) < (2.0, nan)));
assert!(!((2.0, 2.0) < (2.0, nan)));
// TotalEq
assert!(small.equals(&small));
assert!(big.equals(&big));
assert!(!small.equals(&big));
assert!(!big.equals(&small));
// TotalOrd
assert!(small.cmp(&small) == Equal);
assert!(big.cmp(&big) == Equal);