Struct IntoIter

struct IntoIter<T> { ... }

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]);

Implementations

impl<I> IntoIterator for IntoIter<T>

fn into_iter(self: Self) -> I

impl<T> Any for IntoIter<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for IntoIter<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for IntoIter<T>

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

impl<T> Debug for IntoIter<T>

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

impl<T> Freeze for IntoIter<T>

impl<T> From for IntoIter<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FusedIterator for IntoIter<T>

impl<T> Iterator for IntoIter<T>

fn next(self: &mut Self) -> Option<<Self as >::Item>

impl<T> RefUnwindSafe for IntoIter<T>

impl<T> Send for IntoIter<T>

impl<T> Sync for IntoIter<T>

impl<T> Unpin for IntoIter<T>

impl<T> UnsafeUnpin for IntoIter<T>

impl<T> UnwindSafe for IntoIter<T>

impl<T, U> Into for IntoIter<T>

fn into(self: 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 for IntoIter<T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for IntoIter<T>

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