Trait Push

Source
pub trait Push<T>: CanPush<T> {
    // Required method
    fn push(&mut self, val: T) -> Option<Self::PushedOut>;
}
Expand description

A trait for moving data into a collection.

Some containers have limitations on which elements can be stored at once; these collections will “push out” a value after the push happens. A finite-size buffer may push out the oldest value, or a map may push out a value at the same key.

Pushing an item must take a linear amount of time and space with respect to the length of the pushed item. References can be pushed to “copy” data.

Required Methods§

Source

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

Moves the value into the collection, yielding the value that was pushed out, if any.

Implementations on Foreign Types§

Source§

impl Push<char> for String

Source§

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

Source§

impl Push<char> for Vec<u8>

Source§

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

Source§

impl Push<char> for Vec<u16>

Source§

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

Source§

impl Push<char> for Vec<u32>

Source§

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

Source§

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

Source§

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

Source§

impl<'a> Push<&'a str> for OsString

Source§

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

Source§

impl<'a> Push<&'a OsStr> for OsString

Source§

fn push(&mut self, val: &'a OsStr) -> Option<Self::PushedOut>

Source§

impl<'a, T: 'a + Clone> Push<&'a [T]> for Vec<T>

Source§

fn push(&mut self, val: &'a [T]) -> Option<Self::PushedOut>

Source§

impl<K: Hash + Eq, V> Push<(K, V)> for HashMap<K, V>

Source§

fn push(&mut self, (key, val): (K, V)) -> Option<Self::PushedOut>

Source§

impl<T> Push<T> for LinkedList<T>

Source§

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

Source§

impl<T> Push<T> for VecDeque<T>

Source§

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

Source§

impl<T> Push<T> for Vec<T>

Source§

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

Source§

impl<T: Hash + Eq> Push<T> for HashSet<T>

Source§

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

Implementors§

Source§

impl<T: Append> Push<T> for T