[][src]Struct crossbeam_channel::Iter

pub struct Iter<'a, T: 'a> { /* fields omitted */ }

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.iter().collect();

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

Trait Implementations

impl<'a, T> Iterator for Iter<'a, T>[src]

type Item = T

The type of the elements being iterated over.

impl<'a, T> Debug for Iter<'a, T>[src]

impl<'a, T> FusedIterator for Iter<'a, T>[src]

Auto Trait Implementations

impl<'a, T> Send for Iter<'a, T> where
    T: Send

impl<'a, T> Sync for Iter<'a, T> where
    T: Send

impl<'a, T> Unpin for Iter<'a, T>

impl<'a, T> UnwindSafe for Iter<'a, T>

impl<'a, T> RefUnwindSafe for Iter<'a, T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]