[][src]Struct pipe_channel::Receiver

pub struct Receiver<T> { /* fields omitted */ }

The receiving half of a channel.

Methods

impl<T> Receiver<T>[src]

pub fn recv(&mut self) -> Result<T, RecvError>[src]

Receive data sent by the corresponding Sender.

This will block until a value is actually sent, if none is already.

Errors

If the corresponding Sender is already dropped (or gets dropped during the wait), this method will return Err(RecvError).

Examples

Success:

use std::thread;
use pipe_channel::*;

let (mut tx, mut rx) = channel();
let handle = thread::spawn(move || {
    tx.send(35).unwrap();
    tx.send(42).unwrap();
});
assert_eq!(rx.recv().unwrap(), 35);
assert_eq!(rx.recv().unwrap(), 42);
handle.join().unwrap();

Failure:

use pipe_channel::*;
use std::sync::mpsc::RecvError;
use std::mem::drop;

let (tx, mut rx) = channel::<i32>();
drop(tx);
assert_eq!(rx.recv(), Err(RecvError));

Important traits for Iter<'a, T>
pub fn iter(&mut self) -> Iter<T>[src]

Get an iterator over data sent through the channel.

Examples

use pipe_channel::*;
use std::mem::drop;

let (mut tx, mut rx) = channel();
for i in 0..1024 {
    tx.send(i).unwrap();
}
drop(tx);

for (i, j) in rx.iter().take(10).zip(0..10) {
    assert_eq!(i, j);
}
let v1: Vec<_> = rx.into_iter().collect();
let v2: Vec<_> = (10..1024).collect();
assert_eq!(v1, v2);

Trait Implementations

impl<T> AsRawFd for Receiver<T>[src]

impl<T> Debug for Receiver<T>[src]

impl<T> Drop for Receiver<T>[src]

impl<T> FromRawFd for Receiver<T>[src]

impl<T> IntoIterator for Receiver<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

impl<'a, T: 'a> IntoIterator for &'a mut Receiver<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

impl<T> IntoRawFd for Receiver<T>[src]

impl<T: Send> Send for Receiver<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Receiver<T>

impl<T> !Sync for Receiver<T>

impl<T> Unpin for Receiver<T>

impl<T> UnwindSafe for Receiver<T>

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.