Trait WritableVecExt

Source
pub trait WritableVecExt<T: 'static>: Writable<Target = Vec<T>> {
    // Provided methods
    fn push(&mut self, value: T) { ... }
    fn pop(&mut self) -> Option<T> { ... }
    fn insert(&mut self, index: usize, value: T) { ... }
    fn remove(&mut self, index: usize) -> T { ... }
    fn clear(&mut self) { ... }
    fn extend(&mut self, iter: impl IntoIterator<Item = T>) { ... }
    fn truncate(&mut self, len: usize) { ... }
    fn swap_remove(&mut self, index: usize) -> T { ... }
    fn retain(&mut self, f: impl FnMut(&T) -> bool) { ... }
    fn split_off(&mut self, at: usize) -> Vec<T> { ... }
    fn get_mut(&mut self, index: usize) -> Option<WritableRef<'_, Self, T>> { ... }
    fn iter_mut(&mut self) -> WritableValueIterator<'_, Self> 
       where Self: Sized + Clone { ... }
}
Expand description

An extension trait for Writable<Vec<T>> that provides some convenience methods.

Provided Methods§

Source

fn push(&mut self, value: T)

Pushes a new value to the end of the vector.

Source

fn pop(&mut self) -> Option<T>

Pops the last value from the vector.

Source

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

Inserts a new value at the given index.

Source

fn remove(&mut self, index: usize) -> T

Removes the value at the given index.

Source

fn clear(&mut self)

Clears the vector, removing all values.

Source

fn extend(&mut self, iter: impl IntoIterator<Item = T>)

Extends the vector with the given iterator.

Source

fn truncate(&mut self, len: usize)

Truncates the vector to the given length.

Source

fn swap_remove(&mut self, index: usize) -> T

Swaps two values in the vector.

Source

fn retain(&mut self, f: impl FnMut(&T) -> bool)

Retains only the values that match the given predicate.

Source

fn split_off(&mut self, at: usize) -> Vec<T>

Splits the vector into two at the given index.

Source

fn get_mut(&mut self, index: usize) -> Option<WritableRef<'_, Self, T>>

Try to mutably get an element from the vector.

Source

fn iter_mut(&mut self) -> WritableValueIterator<'_, Self>
where Self: Sized + Clone,

Gets an iterator over the values of the vector.

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<T, W> WritableVecExt<T> for W
where T: 'static, W: Writable<Target = Vec<T>>,