Struct IntoIter

pub struct IntoIter<T> { /* private fields */ }

A blocking iterator over messages in a channel.

Each call to next blocks waiting for the next message and then returns it. However, if the channel becomes empty and disconnected, it returns None without blocking.

Examples

use std::thread;
use crossbeam_channel::unbounded;

let (s, r) = unbounded();

thread::spawn(move || {
    s.send(1).unwrap();
    s.send(2).unwrap();
    s.send(3).unwrap();
    drop(s); // Disconnect the channel.
});

// Collect all messages from the channel.
// Note that the call to `collect` blocks until the sender is dropped.
let v: Vec<_> = r.into_iter().collect();

assert_eq!(v, [1, 2, 3]);

Trait Implementations

impl<T> Debug for IntoIter<T>

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

impl<T> FusedIterator for IntoIter<T>

impl<T> Iterator for IntoIter<T>

type Item = T;
fn next(&mut self) -> Option<Self::Item>

Auto Trait Implementations

impl<T> Freeze for IntoIter<T> where Receiver<T>: Freeze,

impl<T> RefUnwindSafe for IntoIter<T> where Receiver<T>: RefUnwindSafe,

impl<T> Send for IntoIter<T> where Receiver<T>: Send,

impl<T> Sync for IntoIter<T> where Receiver<T>: Sync,

impl<T> Unpin for IntoIter<T> where Receiver<T>: Unpin,

impl<T> UnsafeUnpin for IntoIter<T> where Receiver<T>: UnsafeUnpin,

impl<T> UnwindSafe for IntoIter<T> where Receiver<T>: UnwindSafe,

Blanket Implementations

impl<I> IntoIterator for IntoIter<T> where I: Iterator,

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

impl<T> Any for IntoIter<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for IntoIter<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for IntoIter<T> where T: ?Sized,

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

impl<T> From<T> for IntoIter<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for IntoIter<T> 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 IntoIter<T> where U: Into<T>,

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

impl<T, U> TryInto<U> for IntoIter<T> where U: TryFrom<T>,

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