Skip to content

Commit 384550f

Browse files
committed
MAINT: Replace some ArrayView::new_ with from_shape_ptr
1 parent a1cf8c7 commit 384550f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/arraytraits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'a, A, Slice: ?Sized> From<&'a Slice> for ArrayBase<ViewRepr<&'a A>, Ix1>
230230
fn from(slice: &'a Slice) -> Self {
231231
let xs = slice.as_ref();
232232
unsafe {
233-
Self::new_(xs.as_ptr(), Ix1(xs.len()), Ix1(1))
233+
Self::from_shape_ptr(xs.len(), xs.as_ptr())
234234
}
235235
}
236236
}
@@ -256,7 +256,7 @@ impl<'a, A, Slice: ?Sized> From<&'a mut Slice> for ArrayBase<ViewRepr<&'a mut A>
256256
fn from(slice: &'a mut Slice) -> Self {
257257
let xs = slice.as_mut();
258258
unsafe {
259-
Self::new_(xs.as_mut_ptr(), Ix1(xs.len()), Ix1(1))
259+
Self::from_shape_ptr(xs.len(), xs.as_mut_ptr())
260260
}
261261
}
262262
}

src/free_functions.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn rcarr1<A: Clone>(xs: &[A]) -> RcArray<A, Ix1> {
6868

6969
/// Create a zero-dimensional array view borrowing `x`.
7070
pub fn aview0<A>(x: &A) -> ArrayView0<A> {
71-
unsafe { ArrayView::new_(x, Ix0(), Ix0()) }
71+
unsafe { ArrayView::from_shape_ptr(Ix0(), x) }
7272
}
7373

7474
/// Create a one-dimensional array view with elements borrowing `xs`.
@@ -98,8 +98,7 @@ pub fn aview2<A, V: FixedInitializer<Elem=A>>(xs: &[V]) -> ArrayView2<A> {
9898
};
9999
let dim = Ix2(rows, cols);
100100
unsafe {
101-
let strides = dim.default_strides();
102-
ArrayView::new_(data.as_ptr(), dim, strides)
101+
ArrayView::from_shape_ptr(dim, data.as_ptr())
103102
}
104103
}
105104

0 commit comments

Comments
 (0)