Skip to main content

PokeNdArray

Struct PokeNdArray 

Source
pub struct PokeNdArray<'mem, 'facet> { /* private fields */ }
Expand description

Lets you mutate an n-dimensional array (implements mutable facet_core::NdArrayVTable proxies)

Implementations§

Source§

impl<'mem, 'facet> PokeNdArray<'mem, 'facet>

Source

pub const unsafe fn new(value: Poke<'mem, 'facet>, def: NdArrayDef) -> Self

Creates a new poke ndarray.

§Safety

The caller must ensure that def contains valid vtable function pointers that correctly implement the ndarray operations for the actual type, and that the element type matches def.t().

Source

pub fn count(&self) -> usize

Get the total number of elements in the array.

Source

pub fn n_dim(&self) -> usize

Get the number of dimensions.

Source

pub fn dim(&self, i: usize) -> Option<usize>

Get the i-th dimension.

Source

pub fn get(&self, index: usize) -> Option<Peek<'_, 'facet>>

Get a read-only view of the item at the given flat index.

Source

pub fn get_mut(&mut self, index: usize) -> Option<Poke<'_, 'facet>>

Get a mutable view of the item at the given flat index.

Returns None if the underlying ndarray doesn’t provide mutable access or if the index is out of bounds.

Source

pub fn as_mut_ptr(&mut self) -> Result<PtrMut, StrideError>

Get a mutable pointer to the start of the data buffer (if the array is strided).

Source

pub fn byte_stride(&self, i: usize) -> Result<Option<isize>, StrideError>

Get the i-th stride in bytes.

Source

pub const fn def(&self) -> NdArrayDef

Def getter.

Source

pub const fn into_inner(self) -> Poke<'mem, 'facet>

Converts this PokeNdArray back into a Poke.

Source

pub fn as_peek_ndarray(&self) -> PeekNdArray<'_, 'facet>

Returns a read-only PeekNdArray view.

Trait Implementations§

Source§

impl Debug for PokeNdArray<'_, '_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'mem, 'facet> Freeze for PokeNdArray<'mem, 'facet>

§

impl<'mem, 'facet> RefUnwindSafe for PokeNdArray<'mem, 'facet>

§

impl<'mem, 'facet> !Send for PokeNdArray<'mem, 'facet>

§

impl<'mem, 'facet> !Sync for PokeNdArray<'mem, 'facet>

§

impl<'mem, 'facet> Unpin for PokeNdArray<'mem, 'facet>

§

impl<'mem, 'facet> UnsafeUnpin for PokeNdArray<'mem, 'facet>

§

impl<'mem, 'facet> !UnwindSafe for PokeNdArray<'mem, 'facet>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.