nyx_space::linalg::allocator

Trait Allocator

Source
pub trait Allocator<R, C = Const<1>>: Sized + Any
where R: Dim, C: Dim,
{ type Buffer<T: Scalar>: StorageMut<T, R, C> + IsContiguous + Clone + Debug; type BufferUninit<T: Scalar>: RawStorageMut<MaybeUninit<T>, R, C> + IsContiguous; // Required methods fn allocate_uninit<T>(nrows: R, ncols: C) -> Self::BufferUninit<T> where T: Scalar; unsafe fn assume_init<T>(uninit: Self::BufferUninit<T>) -> Self::Buffer<T> where T: Scalar; fn allocate_from_iterator<T, I>( nrows: R, ncols: C, iter: I, ) -> Self::Buffer<T> where T: Scalar, I: IntoIterator<Item = T>; // Provided method fn allocate_from_row_iterator<T, I>( nrows: R, ncols: C, iter: I, ) -> Self::Buffer<T> where T: Scalar, I: IntoIterator<Item = T> { ... } }
Expand description

A matrix allocator of a memory buffer that may contain R::to_usize() * C::to_usize() elements of type T.

An allocator is said to be: − static: if R and C both implement DimName. − dynamic: if either one (or both) of R or C is equal to Dyn.

Every allocator must be both static and dynamic. Though not all implementations may share the same Buffer type.

Required Associated Types§

Source

type Buffer<T: Scalar>: StorageMut<T, R, C> + IsContiguous + Clone + Debug

The type of buffer this allocator can instantiate.

Source

type BufferUninit<T: Scalar>: RawStorageMut<MaybeUninit<T>, R, C> + IsContiguous

The type of buffer with uninitialized components this allocator can instantiate.

Required Methods§

Source

fn allocate_uninit<T>(nrows: R, ncols: C) -> Self::BufferUninit<T>
where T: Scalar,

Allocates a buffer with the given number of rows and columns without initializing its content.

Source

unsafe fn assume_init<T>(uninit: Self::BufferUninit<T>) -> Self::Buffer<T>
where T: Scalar,

Assumes a data buffer to be initialized.

§Safety

The user must make sure that every single entry of the buffer has been initialized, or Undefined Behavior will immediately occur.

Source

fn allocate_from_iterator<T, I>(nrows: R, ncols: C, iter: I) -> Self::Buffer<T>
where T: Scalar, I: IntoIterator<Item = T>,

Allocates a buffer initialized with the content of the given iterator.

Provided Methods§

Source

fn allocate_from_row_iterator<T, I>( nrows: R, ncols: C, iter: I, ) -> Self::Buffer<T>
where T: Scalar, I: IntoIterator<Item = T>,

Allocates a buffer initialized with the content of the given row-major order iterator.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§