diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-23 14:58:09 +0530 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-23 11:43:59 -0800 |
| commit | 84874984526073c3605664e55b09efddbbe7189c (patch) | |
| tree | c576578098006b0500b9565a332b6ccbc42fedcc /src/libcore/array.rs | |
| parent | 3b69d1b941d61250735923f0cf957e1e3d86c4b4 (diff) | |
| parent | 5e616dbd2189844044e039436b7ed16b44f6595a (diff) | |
| download | rust-84874984526073c3605664e55b09efddbbe7189c.tar.gz rust-84874984526073c3605664e55b09efddbbe7189c.zip | |
Rollup merge of #22320 - petrochenkov:eq, r=alexcrichton
Diffstat (limited to 'src/libcore/array.rs')
| -rw-r--r-- | src/libcore/array.rs | 51 |
1 files changed, 8 insertions, 43 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs index e8f6e31756d..0d98cff7e6a 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -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] { } |
