Skip to main content

VecExtensions

Trait VecExtensions 

Source
pub trait VecExtensions<T> {
    // Required methods
    fn push_if_empty(self, value: T) -> Self;
    fn swap_insert(&mut self, index: usize, value: T);
    fn merge(self, other: Self) -> Self;
}

Required Methods§

Source

fn push_if_empty(self, value: T) -> Self

Pushes the provided value to the container if the container is empty

Source

fn swap_insert(&mut self, index: usize, value: T)

Inserts the provided value at index while swapping the item at index to the end of the container

Source

fn merge(self, other: Self) -> Self

Merges two containers one into the other and returns the result. The method is identical to Vec<T>::append but can be used more ergonomically in a fluent calling fashion

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> VecExtensions<T> for Vec<T>

Source§

fn push_if_empty(self, value: T) -> Self

Source§

fn swap_insert(&mut self, index: usize, value: T)

Source§

fn merge(self, other: Self) -> Self

Implementors§