14
14
15
15
use container:: { Container , Mutable } ;
16
16
use cast;
17
- use cmp:: { Eq , Equiv , Ord , TotalOrd , Ordering , Less , Equal , Greater } ;
17
+ use cmp:: { Eq , Equiv , Ord , TotalEq , TotalOrd , Ordering , Less , Equal , Greater } ;
18
18
use clone:: Clone ;
19
19
use iter:: BaseIter ;
20
20
use iter;
@@ -1547,7 +1547,7 @@ pub fn as_mut_buf<T,U>(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U {
1547
1547
1548
1548
// Equality
1549
1549
1550
- fn eq < T : Eq > ( a : & [ T ] , b : & [ T ] ) -> bool {
1550
+ fn eq < T : Eq > ( a : & [ T ] , b : & [ T ] ) -> bool {
1551
1551
let ( a_len, b_len) = ( a. len ( ) , b. len ( ) ) ;
1552
1552
if a_len != b_len { return false ; }
1553
1553
@@ -1556,33 +1556,61 @@ fn eq<T:Eq>(a: &[T], b: &[T]) -> bool {
1556
1556
if a[ i] != b[ i] { return false ; }
1557
1557
i += 1 ;
1558
1558
}
1559
+ true
1560
+ }
1561
+
1562
+ fn equals < T : TotalEq > ( a : & [ T ] , b : & [ T ] ) -> bool {
1563
+ let ( a_len, b_len) = ( a. len ( ) , b. len ( ) ) ;
1564
+ if a_len != b_len { return false ; }
1559
1565
1566
+ let mut i = 0 ;
1567
+ while i < a_len {
1568
+ if !a[ i] . equals ( & b[ i] ) { return false ; }
1569
+ i += 1 ;
1570
+ }
1560
1571
true
1561
1572
}
1562
1573
1563
1574
#[ cfg( notest) ]
1564
1575
impl < ' self , T : Eq > Eq for & ' self [ T ] {
1565
1576
#[ inline( always) ]
1566
- fn eq ( & self , other : & & ' self [ T ] ) -> bool { eq ( ( * self ) , ( * other) ) }
1577
+ fn eq ( & self , other : & & ' self [ T ] ) -> bool { eq ( * self , * other) }
1567
1578
#[ inline( always) ]
1568
- fn ne ( & self , other : & & ' self [ T ] ) -> bool { !( * self ) . eq ( other) }
1579
+ fn ne ( & self , other : & & ' self [ T ] ) -> bool { !self . eq ( other) }
1569
1580
}
1570
1581
1571
-
1572
1582
#[ cfg( notest) ]
1573
1583
impl < T : Eq > Eq for ~[ T ] {
1574
1584
#[ inline( always) ]
1575
- fn eq ( & self , other : & ~[ T ] ) -> bool { eq ( ( * self ) , ( * other) ) }
1585
+ fn eq ( & self , other : & ~[ T ] ) -> bool { eq ( * self , * other) }
1576
1586
#[ inline( always) ]
1577
- fn ne ( & self , other : & ~[ T ] ) -> bool { !( * self ) . eq ( other) }
1587
+ fn ne ( & self , other : & ~[ T ] ) -> bool { !self . eq ( other) }
1578
1588
}
1579
1589
1580
1590
#[ cfg( notest) ]
1581
1591
impl < T : Eq > Eq for @[ T ] {
1582
1592
#[ inline( always) ]
1583
- fn eq ( & self , other : & @[ T ] ) -> bool { eq ( ( * self ) , ( * other) ) }
1593
+ fn eq ( & self , other : & @[ T ] ) -> bool { eq ( * self , * other) }
1594
+ #[ inline( always) ]
1595
+ fn ne ( & self , other : & @[ T ] ) -> bool { !self . eq ( other) }
1596
+ }
1597
+
1598
+ #[ cfg( notest) ]
1599
+ impl < ' self , T : TotalEq > TotalEq for & ' self [ T ] {
1600
+ #[ inline( always) ]
1601
+ fn equals ( & self , other : & & ' self [ T ] ) -> bool { equals ( * self , * other) }
1602
+ }
1603
+
1604
+ #[ cfg( notest) ]
1605
+ impl < T : TotalEq > TotalEq for ~[ T ] {
1606
+ #[ inline( always) ]
1607
+ fn equals ( & self , other : & ~[ T ] ) -> bool { equals ( * self , * other) }
1608
+ }
1609
+
1610
+ #[ cfg( notest) ]
1611
+ impl < T : TotalEq > TotalEq for @[ T ] {
1584
1612
#[ inline( always) ]
1585
- fn ne ( & self , other : & @[ T ] ) -> bool { ! ( * self ) . eq ( other) }
1613
+ fn equals ( & self , other : & @[ T ] ) -> bool { equals ( * self , * other) }
1586
1614
}
1587
1615
1588
1616
#[ cfg( notest) ]
0 commit comments