Insert

Trait Insert 

Source
pub trait Insert<T>: LenMut + PushBack<T> {
    // Required method
    fn insert(&mut self, index: usize, val: T) -> Option<Self::PushedOut>;
}
Expand description

A trait for moving data to a specific index within a collection.

Unlike Push, insertions must take a linear amount of time and space with respect to the length of both the collection and the inserted item.

Required Methods§

Source

fn insert(&mut self, index: usize, val: T) -> Option<Self::PushedOut>

Inserts the value at the given position, yielding the value that was pushed out, if any.

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 Insert<char> for String

Source§

fn insert(&mut self, index: usize, val: char) -> Option<Self::PushedOut>

Source§

impl Insert<char> for Vec<u32>

Source§

fn insert(&mut self, index: usize, val: char) -> Option<Self::PushedOut>

Source§

impl<'a> Insert<&'a str> for String

Source§

fn insert(&mut self, index: usize, val: &'a str) -> Option<Self::PushedOut>

Source§

impl<T> Insert<T> for VecDeque<T>

Source§

fn insert(&mut self, index: usize, val: T) -> Option<Self::PushedOut>

Source§

impl<T> Insert<T> for Vec<T>

Source§

fn insert(&mut self, index: usize, val: T) -> Option<Self::PushedOut>

Implementors§