Struct Drain

pub struct Drain<'a, K: 'a, V: 'a, A: Allocator = Global> { pub(in ::collections::hash::map) base: Drain<'a, K, V, A> }

A draining iterator over the entries of a HashMap.

This struct is created by the drain method on HashMap. See its documentation for more.

Example

use std::collections::HashMap;

let mut map = HashMap::from([
    ("a", 1),
]);
let iter = map.drain();

Fields

base: Drain<'a, K, V, A>

Implementations

impl<'a, K, V, A: Allocator> Drain<'a, K, V, A>

fn iter(&self) -> Iter<'_, K, V>

Returns an iterator of references over the remaining items.

Trait Implementations

impl<'a, K, V, A: Allocator> Iterator for Drain<'a, K, V, A>

type Item = (K, V);
fn next(&mut self) -> Option<(K, V)>
fn size_hint(&self) -> (usize, Option<usize>)
fn fold<B, F>(self, init: B, f: F) -> B
where
    Self: Sized,
    F: FnMut(B, Self::Item) -> B,

impl<K, V, A: Allocator> Debug for Drain<'_, K, V, A> where K: Debug, V: Debug,

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<K, V, A: Allocator> ExactSizeIterator for Drain<'_, K, V, A>

fn len(&self) -> usize

impl<K, V, A: Allocator> FusedIterator for Drain<'_, K, V, A>

Auto Trait Implementations

impl<'a, K, V, A> Freeze for Drain<'a, K, V, A> where Drain<'a, K, V, A>: Freeze,

impl<'a, K, V, A> RefUnwindSafe for Drain<'a, K, V, A> where Drain<'a, K, V, A>: RefUnwindSafe,

impl<'a, K, V, A> Send for Drain<'a, K, V, A> where Drain<'a, K, V, A>: Send,

impl<'a, K, V, A> Sync for Drain<'a, K, V, A> where Drain<'a, K, V, A>: Sync,

impl<'a, K, V, A> Unpin for Drain<'a, K, V, A> where Drain<'a, K, V, A>: Unpin,

impl<'a, K, V, A> UnsafeUnpin for Drain<'a, K, V, A> where Drain<'a, K, V, A>: UnsafeUnpin,

impl<'a, K, V, A> UnwindSafe for Drain<'a, K, V, A> where Drain<'a, K, V, A>: UnwindSafe,

Blanket Implementations

impl<I> IntoIterator for Drain<'a, K, V, A> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for Drain<'a, K, V, A> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Drain<'a, K, V, A> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Drain<'a, K, V, A> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Drain<'a, K, V, A>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Drain<'a, K, V, A> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Drain<'a, K, V, A>

impl<T, U> Into<U> for Drain<'a, K, V, A> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Drain<'a, K, V, A> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Drain<'a, K, V, A> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>