Rollup merge of #22320 - petrochenkov:eq, r=alexcrichton

This commit is contained in:
Manish Goregaokar
2015-02-23 14:58:09 +05:30
committed by Alex Crichton
5 changed files with 85 additions and 102 deletions

View File

@@ -19,8 +19,7 @@ use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use fmt;
use hash::{Hash, self};
use iter::IntoIterator;
use marker::Copy;
use ops::Deref;
use marker::{Copy, Sized};
use option::Option;
use slice::{Iter, IterMut, SliceExt};
@@ -69,47 +68,13 @@ macro_rules! array_impls {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
#[inline]
fn eq(&self, other: &[B; $N]) -> bool {
&self[..] == &other[..]
}
#[inline]
fn ne(&self, other: &[B; $N]) -> bool {
&self[..] != &other[..]
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, A, B, Rhs> PartialEq<Rhs> for [A; $N] where
A: PartialEq<B>,
Rhs: Deref<Target=[B]>,
{
#[inline(always)]
fn eq(&self, other: &Rhs) -> bool {
PartialEq::eq(&self[..], &**other)
}
#[inline(always)]
fn ne(&self, other: &Rhs) -> bool {
PartialEq::ne(&self[..], &**other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, A, B, Lhs> PartialEq<[B; $N]> for Lhs where
A: PartialEq<B>,
Lhs: Deref<Target=[A]>
{
#[inline(always)]
fn eq(&self, other: &[B; $N]) -> bool {
PartialEq::eq(&**self, &other[..])
}
#[inline(always)]
fn ne(&self, other: &[B; $N]) -> bool {
PartialEq::ne(&**self, &other[..])
}
}
// NOTE: some less important impls are omitted to reduce code bloat
__impl_slice_eq1! { [A; $N], [B; $N] }
__impl_slice_eq2! { [A; $N], [B] }
__impl_slice_eq2! { [A; $N], &'b [B] }
__impl_slice_eq2! { [A; $N], &'b mut [B] }
// __impl_slice_eq2! { [A; $N], &'b [B; $N] }
// __impl_slice_eq2! { [A; $N], &'b mut [B; $N] }
#[stable(feature = "rust1", since = "1.0.0")]
impl<T:Eq> Eq for [T; $N] { }