@@ -1501,69 +1501,34 @@ impl<T> Extend<T> for Vec<T> {
1501
1501
}
1502
1502
}
1503
1503
1504
- impl < A , B > PartialEq < Vec < B > > for Vec < A > where A : PartialEq < B > {
1505
- #[ inline]
1506
- fn eq ( & self , other : & Vec < B > ) -> bool { PartialEq :: eq ( & * * self , & * * other) }
1507
- #[ inline]
1508
- fn ne ( & self , other : & Vec < B > ) -> bool { PartialEq :: ne ( & * * self , & * * other) }
1509
- }
1510
-
1511
- macro_rules! impl_eq {
1512
- ( $lhs: ty, $rhs: ty) => {
1513
- impl <' b, A , B > PartialEq <$rhs> for $lhs where A : PartialEq <B > {
1514
- #[ inline]
1515
- fn eq( & self , other: & $rhs) -> bool { PartialEq :: eq( & * * self , & * * other) }
1516
- #[ inline]
1517
- fn ne( & self , other: & $rhs) -> bool { PartialEq :: ne( & * * self , & * * other) }
1518
- }
1519
-
1520
- impl <' b, A , B > PartialEq <$lhs> for $rhs where B : PartialEq <A > {
1521
- #[ inline]
1522
- fn eq( & self , other: & $lhs) -> bool { PartialEq :: eq( & * * self , & * * other) }
1523
- #[ inline]
1524
- fn ne( & self , other: & $lhs) -> bool { PartialEq :: ne( & * * self , & * * other) }
1525
- }
1504
+ __impl_slice_eq1 ! { Vec <A >, Vec <B > }
1505
+ __impl_slice_eq2 ! { Vec <A >, & ' b [ B ] }
1506
+ __impl_slice_eq2 ! { Vec <A >, & ' b mut [ B ] }
1507
+ __impl_slice_eq2 ! { CowVec <' a, A >, & ' b [ B ] , Clone }
1508
+ __impl_slice_eq2 ! { CowVec <' a, A >, & ' b mut [ B ] , Clone }
1509
+ __impl_slice_eq2 ! { CowVec <' a, A >, Vec <B >, Clone }
1510
+
1511
+ macro_rules! array_impls {
1512
+ ( $( $N: expr) +) => {
1513
+ $(
1514
+ // NOTE: some less important impls are omitted to reduce code bloat
1515
+ __impl_slice_eq2! { Vec <A >, [ B ; $N] }
1516
+ __impl_slice_eq2! { Vec <A >, & ' b [ B ; $N] }
1517
+ // __impl_slice_eq2! { Vec<A>, &'b mut [B; $N] }
1518
+ // __impl_slice_eq2! { CowVec<'a, A>, [B; $N], Clone }
1519
+ // __impl_slice_eq2! { CowVec<'a, A>, &'b [B; $N], Clone }
1520
+ // __impl_slice_eq2! { CowVec<'a, A>, &'b mut [B; $N], Clone }
1521
+ ) +
1526
1522
}
1527
1523
}
1528
1524
1529
- impl_eq ! { Vec <A >, & ' b [ B ] }
1530
- impl_eq ! { Vec <A >, & ' b mut [ B ] }
1531
-
1532
- impl < ' a , A , B > PartialEq < Vec < B > > for Cow < ' a , [ A ] > where A : PartialEq < B > + Clone {
1533
- #[ inline]
1534
- fn eq ( & self , other : & Vec < B > ) -> bool { PartialEq :: eq ( & * * self , & * * other) }
1535
- #[ inline]
1536
- fn ne ( & self , other : & Vec < B > ) -> bool { PartialEq :: ne ( & * * self , & * * other) }
1525
+ array_impls ! {
1526
+ 0 1 2 3 4 5 6 7 8 9
1527
+ 10 11 12 13 14 15 16 17 18 19
1528
+ 20 21 22 23 24 25 26 27 28 29
1529
+ 30 31 32
1537
1530
}
1538
1531
1539
- impl < ' a , A , B > PartialEq < Cow < ' a , [ A ] > > for Vec < B > where A : Clone , B : PartialEq < A > {
1540
- #[ inline]
1541
- fn eq ( & self , other : & Cow < ' a , [ A ] > ) -> bool { PartialEq :: eq ( & * * self , & * * other) }
1542
- #[ inline]
1543
- fn ne ( & self , other : & Cow < ' a , [ A ] > ) -> bool { PartialEq :: ne ( & * * self , & * * other) }
1544
- }
1545
-
1546
- macro_rules! impl_eq_for_cowvec {
1547
- ( $rhs: ty) => {
1548
- impl <' a, ' b, A , B > PartialEq <$rhs> for Cow <' a, [ A ] > where A : PartialEq <B > + Clone {
1549
- #[ inline]
1550
- fn eq( & self , other: & $rhs) -> bool { PartialEq :: eq( & * * self , & * * other) }
1551
- #[ inline]
1552
- fn ne( & self , other: & $rhs) -> bool { PartialEq :: ne( & * * self , & * * other) }
1553
- }
1554
-
1555
- impl <' a, ' b, A , B > PartialEq <Cow <' a, [ A ] >> for $rhs where A : Clone , B : PartialEq <A > {
1556
- #[ inline]
1557
- fn eq( & self , other: & Cow <' a, [ A ] >) -> bool { PartialEq :: eq( & * * self , & * * other) }
1558
- #[ inline]
1559
- fn ne( & self , other: & Cow <' a, [ A ] >) -> bool { PartialEq :: ne( & * * self , & * * other) }
1560
- }
1561
- }
1562
- }
1563
-
1564
- impl_eq_for_cowvec ! { & ' b [ B ] }
1565
- impl_eq_for_cowvec ! { & ' b mut [ B ] }
1566
-
1567
1532
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1568
1533
impl < T : PartialOrd > PartialOrd for Vec < T > {
1569
1534
#[ inline]
@@ -2480,7 +2445,7 @@ mod tests {
2480
2445
fn test_into_boxed_slice ( ) {
2481
2446
let xs = vec ! [ 1 , 2 , 3 ] ;
2482
2447
let ys = xs. into_boxed_slice ( ) ;
2483
- assert_eq ! ( ys, [ 1 , 2 , 3 ] ) ;
2448
+ assert_eq ! ( & * ys, [ 1 , 2 , 3 ] ) ;
2484
2449
}
2485
2450
2486
2451
#[ test]
0 commit comments