Skip to content

Commit 9b51170

Browse files
committed
Impl PartialEq for arrays with differing elem types
1 parent 43d088a commit 9b51170

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/arraytraits.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ impl<S, D, I> IndexMut<I> for ArrayBase<S, D>
8181

8282
/// Return `true` if the array shapes and all elements of `self` and
8383
/// `rhs` are equal. Return `false` otherwise.
84-
impl<S, S2, D> PartialEq<ArrayBase<S2, D>> for ArrayBase<S, D>
85-
where D: Dimension,
86-
S: Data,
87-
S2: Data<Elem = S::Elem>,
88-
S::Elem: PartialEq
84+
impl<A, B, S, S2, D> PartialEq<ArrayBase<S2, D>> for ArrayBase<S, D>
85+
where
86+
A: PartialEq<B>,
87+
S: Data<Elem = A>,
88+
S2: Data<Elem = B>,
89+
D: Dimension,
8990
{
9091
fn eq(&self, rhs: &ArrayBase<S2, D>) -> bool {
9192
if self.shape() != rhs.shape() {

src/numeric_util.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ pub fn unrolled_dot<A>(xs: &[A], ys: &[A]) -> A
9696
/// Compute pairwise equality
9797
///
9898
/// `xs` and `ys` must be the same length
99-
pub fn unrolled_eq<A>(xs: &[A], ys: &[A]) -> bool
100-
where A: PartialEq
99+
pub fn unrolled_eq<A, B>(xs: &[A], ys: &[B]) -> bool
100+
where
101+
A: PartialEq<B>,
101102
{
102103
debug_assert_eq!(xs.len(), ys.len());
103104
// eightfold unrolled for performance (this is not done by llvm automatically)

tests/iterators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn inner_iter() {
131131

132132
#[test]
133133
fn inner_iter_corner_cases() {
134-
let a0 = ArcArray::zeros(());
134+
let a0 = ArcArray::<i32, _>::zeros(());
135135
assert_equal(a0.genrows(), vec![aview1(&[0])]);
136136

137137
let a2 = ArcArray::<i32, _>::zeros((0, 3));

0 commit comments

Comments
 (0)