Trait VecUtils

Source
pub trait VecUtils<T> {
    // Required methods
    fn push_if(&mut self, push: T, cond: bool);
    fn push_if_with<F: FnOnce() -> T>(&mut self, cond: bool, f: F);
}
Expand description

Conditional vector push helpers.

Required Methods§

Source

fn push_if(&mut self, push: T, cond: bool)

Pushes the value if cond is true.

Source

fn push_if_with<F: FnOnce() -> T>(&mut self, cond: bool, f: F)

Lazily evaluates and pushes the value if cond is true.

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.

Implementations on Foreign Types§

Source§

impl<T> VecUtils<T> for Vec<T>

Source§

fn push_if(&mut self, push: T, cond: bool)

Source§

fn push_if_with<F: FnOnce() -> T>(&mut self, cond: bool, f: F)

Implementors§