Allocator in nalgebra::base::allocator - Rust
Description: A matrix allocator of a memory buffer that may contain `R::to_usize() * C::to_usize()` elements of type `T`.
Keywords: rust, rustlang, rust-lang, Allocator

# Trait nalgebra::base::allocator::Allocator

source ·

    pub trait Allocator<T, R: Dim, C: Dim = U1>: Any + Sized {
        type Buffer: StorageMut<T, R, C> + IsContiguous + Clone + Debug;
        type BufferUninit: RawStorageMut<MaybeUninit<T>, R, C> + IsContiguous;

        fn allocate_uninit(nrows: R, ncols: C) -> Self::BufferUninit;
        unsafe fn assume_init(uninit: Self::BufferUninit) -> Self::Buffer;
        fn allocate_from_iterator<I: IntoIterator<Item = T>>(
            nrows: R,
            ncols: C,
            iter: I
        ) -> Self::Buffer;

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

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: StorageMut<T, R, C> + IsContiguous + Clone + Debug

The type of buffer this allocator can instanciate.

source

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

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

## Required Methods§

source

#### fn allocate_uninit(nrows: R, ncols: C) -> Self::BufferUninit

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

source

#### unsafe fn assume_init(uninit: Self::BufferUninit) -> Self::Buffer

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<I: IntoIterator<Item = T>>(
nrows: R,
ncols: C,
iter: I
) -> Self::Buffer

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

## Provided Methods§

source

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

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

## Implementors§

source§

### impl<T: Scalar, C: Dim> Allocator<T, Dyn, C> for DefaultAllocator

§

#### type Buffer = VecStorage<T, Dyn, C>

§

#### type BufferUninit = VecStorage<MaybeUninit<T>, Dyn, C>

source§

### impl<T: Scalar, R: DimName> Allocator<T, R, Dyn> for DefaultAllocator

§

#### type Buffer = VecStorage<T, R, Dyn>

§

#### type BufferUninit = VecStorage<MaybeUninit<T>, R, Dyn>

source§

### impl<T: Scalar, const R: usize, const C: usize> Allocator<T, Const<R>, Const<C>> for DefaultAllocator

§

#### type Buffer = ArrayStorage<T, R, C>

§

#### type BufferUninit = ArrayStorage<MaybeUninit<T>, R, C>