Skip to main content

DenseData

Trait DenseData 

Source
pub unsafe trait DenseData {
    type Elem;

    // Required method
    fn as_slice(&self) -> &[Self::Elem];
}
Expand description

Various view types (types such as MatrixView that add semantic meaning to blobs of data) need both immutable and mutable variants.

This trait can be implemented by wrappers for immutable and mutable slice references, allowing for a common code path for immutable and mutable view types.

The main goal is to provide a way of retrieving an underlying dense slice, which can then be used as the building block for higher level abstractions.

§Safety

This trait is unsafe because it requires as_slice to be idempotent (and unsafe code relies on this).

In other words: as_slice must always return the same slice with the same length.

Required Associated Types§

Required Methods§

Source

fn as_slice(&self) -> &[Self::Elem]

Return the underlying data as a slice.

Implementations on Foreign Types§

Source§

impl<T> DenseData for &[T]

Source§

type Elem = T

Source§

fn as_slice(&self) -> &[Self::Elem]

Source§

impl<T> DenseData for &mut [T]

Source§

type Elem = T

Source§

fn as_slice(&self) -> &[Self::Elem]

Source§

impl<T> DenseData for Box<[T]>

Source§

type Elem = T

Source§

fn as_slice(&self) -> &[Self::Elem]

Implementors§