1414
1515use container:: { Container , Mutable } ;
1616use cast;
17- use cmp:: { Eq , Equiv , Ord , TotalOrd , Ordering , Less , Equal , Greater } ;
17+ use cmp:: { Eq , Equiv , Ord , TotalEq , TotalOrd , Ordering , Less , Equal , Greater } ;
1818use clone:: Clone ;
1919use iter:: BaseIter ;
2020use iter;
@@ -1547,7 +1547,7 @@ pub fn as_mut_buf<T,U>(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U {
15471547
15481548// Equality
15491549
1550- fn eq < T : Eq > ( a : & [ T ] , b : & [ T ] ) -> bool {
1550+ fn eq < T : Eq > ( a : & [ T ] , b : & [ T ] ) -> bool {
15511551 let ( a_len, b_len) = ( a. len ( ) , b. len ( ) ) ;
15521552 if a_len != b_len { return false ; }
15531553
@@ -1556,33 +1556,61 @@ fn eq<T:Eq>(a: &[T], b: &[T]) -> bool {
15561556 if a[ i] != b[ i] { return false ; }
15571557 i += 1 ;
15581558 }
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 ; }
15591565
1566+ let mut i = 0 ;
1567+ while i < a_len {
1568+ if !a[ i] . equals ( & b[ i] ) { return false ; }
1569+ i += 1 ;
1570+ }
15601571 true
15611572}
15621573
15631574#[ cfg( notest) ]
15641575impl < ' self , T : Eq > Eq for & ' self [ T ] {
15651576 #[ inline( always) ]
1566- fn eq ( & self , other : & & ' self [ T ] ) -> bool { eq ( ( * self ) , ( * other) ) }
1577+ fn eq ( & self , other : & & ' self [ T ] ) -> bool { eq ( * self , * other) }
15671578 #[ inline( always) ]
1568- fn ne ( & self , other : & & ' self [ T ] ) -> bool { !( * self ) . eq ( other) }
1579+ fn ne ( & self , other : & & ' self [ T ] ) -> bool { !self . eq ( other) }
15691580}
15701581
1571-
15721582#[ cfg( notest) ]
15731583impl < T : Eq > Eq for ~[ T ] {
15741584 #[ inline( always) ]
1575- fn eq ( & self , other : & ~[ T ] ) -> bool { eq ( ( * self ) , ( * other) ) }
1585+ fn eq ( & self , other : & ~[ T ] ) -> bool { eq ( * self , * other) }
15761586 #[ inline( always) ]
1577- fn ne ( & self , other : & ~[ T ] ) -> bool { !( * self ) . eq ( other) }
1587+ fn ne ( & self , other : & ~[ T ] ) -> bool { !self . eq ( other) }
15781588}
15791589
15801590#[ cfg( notest) ]
15811591impl < T : Eq > Eq for @[ T ] {
15821592 #[ 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 ] {
15841612 #[ inline( always) ]
1585- fn ne ( & self , other : & @[ T ] ) -> bool { ! ( * self ) . eq ( other) }
1613+ fn equals ( & self , other : & @[ T ] ) -> bool { equals ( * self , * other) }
15861614}
15871615
15881616#[ cfg( notest) ]
0 commit comments