VecHelper

Trait VecHelper 

Source
pub trait VecHelper {
    type Item;

    // Required methods
    fn find(&mut self, ident: Ident) -> Option<&mut Self::Item>;
    fn find_or_insert<F>(&mut self, ident: Ident, f: F) -> &mut Self::Item
       where F: FnOnce(Ident) -> Self::Item;
}
Expand description

Helper trait that implements additional methods for vectors.

Required Associated Types§

Source

type Item

Item stored in the vector.

Required Methods§

Source

fn find(&mut self, ident: Ident) -> Option<&mut Self::Item>

Try to find the object with the passed ident in the vector. If it was not found None is returned.

Source

fn find_or_insert<F>(&mut self, ident: Ident, f: F) -> &mut Self::Item
where F: FnOnce(Ident) -> Self::Item,

Try to find the object with the passed ident in the vector. If it was not found, a new one is created by invoking f.

Returns a mutable reference either to the found or the newly created object.

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<X, T> VecHelper for X
where X: DerefMut<Target = Vec<T>>, T: WithIdent,

Source§

type Item = T