Skip to main content

VectorHost

Trait VectorHost 

Source
pub trait VectorHost:
    Vector
    + Index<IndexType, Output = Self::T>
    + IndexMut<IndexType, Output = Self::T> {
    // Required methods
    fn as_slice(&self) -> &[Self::T];
    fn as_mut_slice(&mut self) -> &mut [Self::T];
}
Expand description

A vector hosted on the CPU, supporting direct indexing and slice access.

This trait extends Vector with the ability to directly access vector elements via indexing (v[i]) and to get slices of the underlying data. This is useful for algorithms that need direct CPU-side access to vector data. GPU vectors typically do not implement this trait.

Required Methods§

Source

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

Get the vector data as an immutable slice.

Source

fn as_mut_slice(&mut self) -> &mut [Self::T]

Get the vector data as a mutable slice.

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§