Struct sp_std::sync::mpsc::TryIter1.15.0[][src]

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

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

Trait Implementations

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

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

type Item = T

The type of the elements being iterated over.

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

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

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