diff --git a/src/impls.rs b/src/impls.rs index a8e68c30d7..6d7c2be50e 100644 --- a/src/impls.rs +++ b/src/impls.rs @@ -52,7 +52,7 @@ impl PartialOrd for GenericArray where N: ArrayLength { fn partial_cmp(&self, other: &GenericArray) -> Option { - PartialOrd::partial_cmp(&self, &other) + PartialOrd::partial_cmp(self.as_slice(), other.as_slice()) } } @@ -60,7 +60,7 @@ impl Ord for GenericArray where N: ArrayLength { fn cmp(&self, other: &GenericArray) -> Ordering { - Ord::cmp(&self, &other) + Ord::cmp(self.as_slice(), other.as_slice()) } } diff --git a/tests/mod.rs b/tests/mod.rs index 8818d8ccde..577dbccda7 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -112,6 +112,12 @@ fn test_empty_macro() { let arr = arr![f32;]; } +#[test] +fn test_cmp() { + use core::cmp::Ordering; + assert_eq!(arr![u8; 0x00].cmp(&arr![u8; 0x00]), Ordering::Equal); +} + /// This test should cause a helpful compile error if uncommented. // #[test] // fn test_empty_macro2(){