Struct ergo_sync::ch::TryIter
[−]
[src]
pub struct TryIter<'a, T> where
T: 'a, { /* fields omitted */ }
An iterator that receives messages until the channel is empty or disconnected.
Each call to next
will return a message if there is at least one in the channel. The iterator
will never block waiting for new messages.
Examples
use std::thread; use std::time::Duration; use crossbeam_channel::unbounded; let (tx, rx) = unbounded::<i32>(); thread::spawn(move || { thread::sleep(Duration::from_secs(1)); tx.send(1).unwrap(); tx.send(2).unwrap(); thread::sleep(Duration::from_secs(2)); tx.send(3).unwrap(); }); thread::sleep(Duration::from_secs(2)); let v: Vec<_> = rx.try_iter().collect(); assert_eq!(v, [1, 2]);
Trait Implementations
impl<'a, T> Debug for TryIter<'a, T> where
T: 'a + Debug,
[src]
T: 'a + Debug,