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.

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().

Required Methods§

source

fn len(&self) -> usize

source

fn at(&self, i: usize) -> T

Provided Methods§

source

fn map<U, F: Fn(T) -> U>(self, f: F) -> MapFn<Self, F, T>
where Self: Sized,

source

fn to_vec(&self) -> Vec<T>

Implementations on Foreign Types§

source§

impl<'a, T, V> VectorFn<T> for &'a V
where V: VectorFn<T> + ?Sized,

source§

fn len(&self) -> usize

source§

fn at(&self, i: usize) -> T

source§

impl<'a, T, V> VectorFn<T> for &'a mut V
where V: VectorFn<T> + ?Sized,

source§

fn len(&self) -> usize

source§

fn at(&self, i: usize) -> T

Implementors§

source§

impl VectorFn<usize> for RangeFn

source§

impl<R, V, T> VectorFn<T> for RingElVectorViewFn<R, V, T>
where R: RingStore, R::Type: RingBase<Element = T>, V: VectorView<T>,

source§

impl<T, V> VectorFn<T> for SubvectorFn<T, V>
where V: VectorFn<T>,

source§

impl<V, F, T, U> VectorFn<U> for MapFn<V, F, T>
where V: VectorFn<T>, F: Fn(T) -> U,

source§

impl<V, T> VectorFn<T> for VectorViewFn<V, T>
where T: Clone, V: VectorView<T>,