Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,15 +1277,15 @@ pub type Ixs = isize;
// may change in the future.
//
// [`.offset()`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset-1
pub struct ArrayBase<S, D>
where S: RawData
pub struct ArrayBase<S, D, A = <S as RawData>::Elem>
where S: RawData<Elem = A>
{
/// Data buffer / ownership information. (If owned, contains the data
/// buffer; if borrowed, contains the lifetime and mutability.)
data: S,
/// A non-null pointer into the buffer held by `data`; may point anywhere
/// in its range. If `S: Data`, this pointer must be aligned.
ptr: std::ptr::NonNull<S::Elem>,
ptr: std::ptr::NonNull<A>,
/// The lengths of the axes.
dim: D,
/// The element count stride per axis. To be parsed as `isize`.
Expand Down
14 changes: 14 additions & 0 deletions tests/variance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use ndarray::{Array1, ArrayView1};

fn arrayview_covariant<'a: 'b, 'b>(x: ArrayView1<'a, f64>) -> ArrayView1<'b, f64>
{
x
}

#[test]
fn test_covariance()
{
let x = Array1::zeros(2);
let shorter_view = arrayview_covariant(x.view());
assert_eq!(shorter_view[0], 0.0);
}