-
Notifications
You must be signed in to change notification settings - Fork 356
Open
Labels
Description
While working on updating ndarray-npy for ndarray 0.17.1, I noticed that the following doesn't compile:
use ndarray::{ArrayRef2, array};
fn main() {
let arr = array![[1i32, 2, 3], [4, 5, 6]];
let arr_ref: &ArrayRef2<i32> = &arr;
assert_eq!(arr, arr_ref);
}The error message is the following:
Compiling playground v0.0.1 (/playground)
error[E0277]: can't compare `ArrayBase<OwnedRepr<i32>, Dim<[usize; 2]>, i32>` with `&ArrayRef<i32, Dim<[usize; 2]>>`
--> src/main.rs:6:5
|
6 | assert_eq!(arr, arr_ref);
| ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `ArrayBase<OwnedRepr<i32>, Dim<[usize; 2]>, i32> == &ArrayRef<i32, Dim<[usize; 2]>>`
|
= help: the trait `PartialEq<&ArrayRef<i32, Dim<[usize; 2]>>>` is not implemented for `ArrayBase<OwnedRepr<i32>, Dim<[usize; 2]>, i32>`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider dereferencing both sides of the expression
--> /playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/macros/mod.rs:46:22
|
46| if !(**left_val == **right_val) {
| + +
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 1 previous error
While there are several ways to work around this, it would be nice to make this example work as-is by adding the necessary PartialEq impl.