Trait DrainContainer

Source
pub trait DrainContainer {
    type Item<'a>
       where Self: 'a;
    type DrainIter<'a>: Iterator<Item = Self::Item<'a>>
       where Self: 'a;

    // Required method
    fn drain(&mut self) -> Self::DrainIter<'_>;
}
Expand description

A container that can drain itself.

Draining the container presents items in an implementation-specific order. The container is in an undefined state after calling [drain]. Dropping the iterator also leaves the container in an undefined state.

Required Associated Types§

Source

type Item<'a> where Self: 'a

The type of elements when draining the container.

Source

type DrainIter<'a>: Iterator<Item = Self::Item<'a>> where Self: 'a

Iterator type when draining the container.

Required Methods§

Source

fn drain(&mut self) -> Self::DrainIter<'_>

Returns an iterator that drains the contents of this container. Drain leaves the container in an undefined state.

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> DrainContainer for Rc<T>
where T: IterContainer,

Source§

type Item<'a> = <T as IterContainer>::ItemRef<'a> where Rc<T>: 'a

Source§

type DrainIter<'a> = <T as IterContainer>::Iter<'a> where Rc<T>: 'a

Source§

fn drain(&mut self) -> <Rc<T> as DrainContainer>::DrainIter<'_>

Source§

impl<T> DrainContainer for Arc<T>
where T: IterContainer,

Source§

type Item<'a> = <T as IterContainer>::ItemRef<'a> where Arc<T>: 'a

Source§

type DrainIter<'a> = <T as IterContainer>::Iter<'a> where Arc<T>: 'a

Source§

fn drain(&mut self) -> <Arc<T> as DrainContainer>::DrainIter<'_>

Source§

impl<T> DrainContainer for Vec<T>

Source§

type Item<'a> = T where T: 'a

Source§

type DrainIter<'a> = Drain<'a, T> where Vec<T>: 'a

Source§

fn drain(&mut self) -> <Vec<T> as DrainContainer>::DrainIter<'_>

Implementors§