1.15.0[][src]Struct mandelbrot::views::prelude::mpsc::TryIter

pub struct TryIter<'a, T> where
    T: 'a, 
{ rx: &'a Receiver<T>, }

An iterator that attempts to yield all pending values for a Receiver, created by try_iter.

None will be returned when there are no pending values remaining or if the corresponding channel has hung up.

This iterator will never block the caller in order to wait for data to become available. Instead, it will return None.

Examples

use std::sync::mpsc::channel;
use std::thread;
use std::time::Duration;

let (sender, receiver) = channel();

// Nothing is in the buffer yet
assert!(receiver.try_iter().next().is_none());
println!("Nothing in the buffer...");

thread::spawn(move || {
    sender.send(1).unwrap();
    sender.send(2).unwrap();
    sender.send(3).unwrap();
});

println!("Going to sleep...");
thread::sleep(Duration::from_secs(2)); // block for two seconds

for x in receiver.try_iter() {
    println!("Got: {}", x);
}

Fields

rx: &'a Receiver<T>

Trait Implementations

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

type Item = T

The type of the elements being iterated over.

impl<'a, T> Debug for TryIter<'a, T> where
    T: 'a + Debug
[src]

Auto Trait Implementations

impl<'a, T> !Send for TryIter<'a, T>

impl<'a, T> !Sync for TryIter<'a, T>

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

impl<'a, T> !UnwindSafe for TryIter<'a, T>

impl<'a, T> !RefUnwindSafe for TryIter<'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]

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,