SizedVectorArray

Trait SizedVectorArray 

Source
pub trait SizedVectorArray<T: Sized, const D: usize, V: RawVector<T, D>, I>: VectorArray<T, D, V, I> {
    // Required methods
    fn ptr(&self) -> *const V;
    fn ptr_mut(&mut self) -> *mut V;
    fn len(&self) -> usize;
    fn convert_index(&self, index: I) -> usize;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn vec_split_fast<'a>(&'a self) -> [FastAccessor<'a, T, D, V, I, Self>; D] { ... }
    fn vec_split_fast_mut<'a>(
        &'a mut self,
    ) -> [FastAccessorMut<'a, T, D, V, I, Self>; D] { ... }
}
Expand description

Trait to be implemented for all types that are arrays of some sort, contain only vectors, and have a way to access their internal pointers. Used to allow the use of FastAccessors.

Required Methods§

Source

fn ptr(&self) -> *const V

Source

fn ptr_mut(&mut self) -> *mut V

Source

fn len(&self) -> usize

Source

fn convert_index(&self, index: I) -> usize

Please make this inline for speed

Provided Methods§

Source

fn is_empty(&self) -> bool

Source

fn vec_split_fast<'a>(&'a self) -> [FastAccessor<'a, T, D, V, I, Self>; D]

Source

fn vec_split_fast_mut<'a>( &'a mut self, ) -> [FastAccessorMut<'a, T, D, V, I, Self>; D]

Examples found in repository?
examples/simple_splitting.rs (line 8)
6fn main() {
7    let mut array = [[0.0, 0.0]; 10];
8    let [mut x_array, mut y_array] = array.vec_split_fast_mut();
9    for (i, item) in x_array.iter_mut().enumerate() {
10        *item = i as f64 / 10.0;
11    }
12    for (i, item) in y_array.iter_mut().enumerate() {
13        *item = i as f64 * 2.0;
14    }
15    for item in x_array.iter() {
16        println!("X {item}");
17    }
18    for item in y_array.iter() {
19        println!("Y {item}");
20    }
21}

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.

Implementations on Foreign Types§

Source§

impl<T, const D: usize, V: RawVector<T, D>> SizedVectorArray<T, D, V, usize> for &mut [V]

Source§

fn ptr(&self) -> *const V

Source§

fn ptr_mut(&mut self) -> *mut V

Source§

fn len(&self) -> usize

Source§

fn convert_index(&self, index: usize) -> usize

Source§

impl<T, const D: usize, V: RawVector<T, D>> SizedVectorArray<T, D, V, usize> for Vec<V>

Source§

fn ptr(&self) -> *const V

Source§

fn ptr_mut(&mut self) -> *mut V

Source§

fn len(&self) -> usize

Source§

fn convert_index(&self, index: usize) -> usize

Source§

impl<T, const D: usize, V: RawVector<T, D>, const A: usize> SizedVectorArray<T, D, V, usize> for [V; A]

Source§

fn ptr(&self) -> *const V

Source§

fn ptr_mut(&mut self) -> *mut V

Source§

fn len(&self) -> usize

Source§

fn convert_index(&self, index: usize) -> usize

Implementors§