auto merge of #13102 : huonw/rust/totaleq-deriving, r=thestinger
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:
commit
903e83889a
23 changed files with 74 additions and 208 deletions
|
|
@ -39,9 +39,6 @@ pub fn main() {
|
|||
assert_eq!(*e1 == *e2, eq);
|
||||
assert_eq!(*e1 != *e2, !eq);
|
||||
|
||||
// TotalEq
|
||||
assert_eq!(e1.equals(e2), eq);
|
||||
|
||||
// Ord
|
||||
assert_eq!(*e1 < *e2, lt);
|
||||
assert_eq!(*e1 > *e2, gt);
|
||||
|
|
|
|||
|
|
@ -35,9 +35,6 @@ pub fn main() {
|
|||
assert_eq!(*es1 == *es2, eq);
|
||||
assert_eq!(*es1 != *es2, !eq);
|
||||
|
||||
// TotalEq
|
||||
assert_eq!(es1.equals(es2), eq);
|
||||
|
||||
// Ord
|
||||
assert_eq!(*es1 < *es2, lt);
|
||||
assert_eq!(*es1 > *es2, gt);
|
||||
|
|
|
|||
|
|
@ -35,9 +35,6 @@ pub fn main() {
|
|||
assert_eq!(*s1 == *s2, eq);
|
||||
assert_eq!(*s1 != *s2, !eq);
|
||||
|
||||
// TotalEq
|
||||
assert_eq!(s1.equals(s2), eq);
|
||||
|
||||
// Ord
|
||||
assert_eq!(*s1 < *s2, lt);
|
||||
assert_eq!(*s1 > *s2, gt);
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@ pub fn main() {
|
|||
assert_eq!(*ts1 == *ts2, eq);
|
||||
assert_eq!(*ts1 != *ts2, !eq);
|
||||
|
||||
// TotalEq
|
||||
assert_eq!(ts1.equals(ts2), eq);
|
||||
|
||||
// Ord
|
||||
assert_eq!(*ts1 < *ts2, lt);
|
||||
assert_eq!(*ts1 > *ts2, gt);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ impl Ord for FailCmp {
|
|||
fn lt(&self, _: &FailCmp) -> bool { fail!("lt") }
|
||||
}
|
||||
|
||||
impl TotalEq for FailCmp {
|
||||
fn equals(&self, _: &FailCmp) -> bool { fail!("equals") }
|
||||
}
|
||||
impl TotalEq for FailCmp {}
|
||||
|
||||
impl TotalOrd for FailCmp {
|
||||
fn cmp(&self, _: &FailCmp) -> Ordering { fail!("cmp") }
|
||||
|
|
@ -41,6 +39,5 @@ pub fn main() {
|
|||
|
||||
assert!(a != b);
|
||||
assert!(a < b);
|
||||
assert!(!a.equals(&b));
|
||||
assert_eq!(a.cmp(&b), ::std::cmp::Less);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,6 @@ struct A<'a> {
|
|||
pub fn main() {
|
||||
let (a, b) = (A { x: &1 }, A { x: &2 });
|
||||
|
||||
assert!(a.equals(&a));
|
||||
assert!(b.equals(&b));
|
||||
|
||||
|
||||
assert_eq!(a.cmp(&a), Equal);
|
||||
assert_eq!(b.cmp(&b), Equal);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue