[][src]Type Definition ndarray::RawArrayViewMut

type RawArrayViewMut<A, D> = ArrayBase<RawViewRepr<*mut A>, D>;

A mutable array view without a lifetime.

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

The RawArrayViewMut<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 RawArrayView.

Warning

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

Methods

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

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

Create an RawArrayViewMut<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 unsafe fn deref_into_view_mut<'a>(self) -> ArrayViewMut<'a, A, D>[src]

Converts to a mutable 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 RawArrayViewMut<A, D>[src]

type Item = *mut A

The element produced per iteration.

type Dim = D

Dimension type

type Ptr = *mut A

type Stride = isize