[][src]Type Definition ndarray::RawArrayView

type RawArrayView<A, D> = ArrayBase<RawViewRepr<*const A>, D>;

A read-only array view without a lifetime.

This is similar to ArrayView but does not carry any lifetime or ownership information, and its data cannot be read without an unsafe conversion into an ArrayView. The relationship between RawArrayView and ArrayView is somewhat analogous to the relationship between *const T and &T, but RawArrayView has additional requirements that *const T does not, such as alignment and non-nullness.

The RawArrayView<A, D> is parameterized by A for the element type and D for the dimensionality.

Raw array views have all the methods of an array (see ArrayBase).

See also RawArrayViewMut.

Warning

You can't use this type wih an arbitrary raw pointer; see from_shape_ptr for details.

Methods

impl<A, D> RawArrayView<A, D> where
    D: Dimension
[src]

pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *const A) -> Self where
    Sh: Into<StrideShape<D>>, 
[src]

Create an RawArrayView<A, D> from shape information and a raw pointer to the elements.

Unsafe because caller is responsible for ensuring all of the following:

  • ptr must be non-null and aligned, and it must be safe to .offset() ptr by zero.

  • It must be safe to .offset() the pointer repeatedly along all axes and calculate the counts for the .offset() calls without overflow, even if the array is empty or the elements are zero-sized.

    In other words,

    • All possible pointers generated by moving along all axes must be in bounds or one byte past the end of a single allocation with element type A. The only exceptions are if the array is empty or the element type is zero-sized. In these cases, ptr may be dangling, but it must still be safe to .offset() the pointer along the axes.

    • The offset in units of bytes between the least address and greatest address by moving along all axes must not exceed isize::MAX. This constraint prevents the computed offset, in bytes, from overflowing isize regardless of the starting point due to past offsets.

    • The offset in units of A between the least address and greatest address by moving along all axes must not exceed isize::MAX. This constraint prevents overflow when calculating the count parameter to .offset() regardless of the starting point due to past offsets.

  • The product of non-zero axis lengths must not exceed isize::MAX.

pub unsafe fn deref_into_view<'a>(self) -> ArrayView<'a, A, D>[src]

Converts to a read-only view of the array.

Warning from a safety standpoint, this is equivalent to dereferencing a raw pointer for every element in the array. You must ensure that all of the data is valid and choose the correct lifetime.

pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)[src]

Split the array view along axis and return one array pointer strictly before the split and one array pointer after the split.

Panics if axis or index is out of bounds.

Trait Implementations

impl<A, D: Dimension> NdProducer for RawArrayView<A, D>[src]

type Item = *const A

The element produced per iteration.

type Dim = D

Dimension type

type Ptr = *const A

type Stride = isize