Trait Vector

Source
pub trait Vector {
    type Scalar: Copy;

    // Required methods
    fn add(&self, other: &Self) -> Self;
    fn subtract(&self, other: &Self) -> Self;
    fn scale(&self, scalar: Self::Scalar) -> Self;
    fn dot(&self, other: &Self) -> Self::Scalar;
    fn cross(&self, other: &Self) -> Self;
    fn length(&self) -> Self::Scalar;
    fn normalize(&self) -> Self;
    fn size(&self) -> usize;
    fn at(&self, index: usize) -> Self::Scalar;
    fn update(&mut self, index: usize, value: Self::Scalar);
}
Expand description

Generalized Vector operations that can be implemented by any vector like type.

Required Associated Types§

Required Methods§

Source

fn add(&self, other: &Self) -> Self

Source

fn subtract(&self, other: &Self) -> Self

Source

fn scale(&self, scalar: Self::Scalar) -> Self

Source

fn dot(&self, other: &Self) -> Self::Scalar

Source

fn cross(&self, other: &Self) -> Self

Source

fn length(&self) -> Self::Scalar

Source

fn normalize(&self) -> Self

Source

fn size(&self) -> usize

Source

fn at(&self, index: usize) -> Self::Scalar

Source

fn update(&mut self, index: usize, value: Self::Scalar)

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§

Source§

impl<T> Vector for T
where T: AsMut<[f32]> + AsRef<[f32]> + Default,