Trait perpendicular::MapVector [−][src]
pub trait MapVector<T, const DIM: usize> { fn map<U, F: FnMut(T) -> U>(self, func: F) -> Vector<U, DIM>; }
Expand description
Trait to allow for mapping Vector and &Vector
Required methods
Map an operation over every element of the vector
use perpendicular::MapVector; let v = Vector::new((1, 2, 3, 4)); assert_eq!(v.clone().map(|i| i * 3), Vector::new((3, 6, 9, 12))); assert_eq!(v.clone().map(|i| -i), Vector::new((-1, -2, -3, -4)));