Trait feanor_math::vector::vec_fn::VectorFn
source · pub trait VectorFn<T> {
// Required methods
fn len(&self) -> usize;
fn at(&self, i: usize) -> T;
// Provided methods
fn map<U, F: Fn(T) -> U>(self, f: F) -> MapFn<Self, F, T>
where Self: Sized { ... }
fn to_vec(&self) -> Vec<T> { ... }
}Expand description
A trait for objects that have the structure of a one-dimensional array, and can produce objects at each entry. In other words, this is like a “random-access iterator”.
In my experience, in most cases, you want to use std::iter::ExactSizeIterator instead.
§Related traits
If the entries are owned by the object, consider using the trait crate::vector::VectorView.
Instead of returning entries by value, it returns entries by reference. Otherwise, it is often
better to use an std::iter::ExactSizeIterator, as it allows move-semantics and can avoid
cloning (if random access is not necessary).
§Blanket implementations
There are many kinds of blanket implementations thinkable, e.g.
impl<T: Clone, V> VectorFn<T> for VectorView<T> { ... }or
impl<'a, T, V> VectorFn<&'a T> for &'a VectorView<T> { ... }However, these do not represent the standard use cases and clutter the space of
possible implementations. Instead, use the function crate::vector::vec_fn::IntoVectorFn::into_fn().