about summary refs log tree commit diff
path: root/src/libcore/array.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/array.rs')
-rw-r--r--src/libcore/array.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs
index 60765e82cb4..ffaf35414ea 100644
--- a/src/libcore/array.rs
+++ b/src/libcore/array.rs
@@ -18,6 +18,7 @@ use clone::Clone;
 use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
 use fmt;
 use kinds::Copy;
+use ops::Deref;
 use option::Option;
 
 // macro for implementing n-ary tuple functions and operations
@@ -39,17 +40,37 @@ macro_rules! array_impls {
             }
 
             #[unstable = "waiting for PartialEq to stabilize"]
-            impl<T:PartialEq> PartialEq for [T, ..$N] {
+            impl<A, B> PartialEq<[B, ..$N]> for [A, ..$N] where A: PartialEq<B> {
                 #[inline]
-                fn eq(&self, other: &[T, ..$N]) -> bool {
+                fn eq(&self, other: &[B, ..$N]) -> bool {
                     self[] == other[]
                 }
                 #[inline]
-                fn ne(&self, other: &[T, ..$N]) -> bool {
+                fn ne(&self, other: &[B, ..$N]) -> bool {
                     self[] != other[]
                 }
             }
 
+            impl<'a, A, B, Rhs> PartialEq<Rhs> for [A, ..$N] where
+                A: PartialEq<B>,
+                Rhs: Deref<[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) }
+            }
+
+            impl<'a, A, B, Lhs> PartialEq<[B, ..$N]> for Lhs where
+                A: PartialEq<B>,
+                Lhs: Deref<[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[]) }
+            }
+
             #[unstable = "waiting for Eq to stabilize"]
             impl<T:Eq> Eq for [T, ..$N] { }