Struct Iter

pub struct Iter<'a, T: 'a> { pub(in ::sync::mpsc) rx: &'a Receiver<T> }

An iterator over messages on a Receiver, created by iter.

This iterator will block whenever next is called, waiting for a new message, and None will be returned when the corresponding channel has hung up.

Examples

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

let (send, recv) = channel();

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

for x in recv.iter() {
    println!("Got: {x}");
}

Fields

rx: &'a Receiver<T>

Trait Implementations

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

type Item = T;
fn next(&mut self) -> Option<T>

impl<'a, T: Debug + 'a> Debug for Iter<'a, T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

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

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

impl<'a, T> Freeze for Iter<'a, T> where &'a Receiver<T>: Freeze,

impl<'a, T> RefUnwindSafe for Iter<'a, T> where &'a Receiver<T>: RefUnwindSafe,

impl<'a, T> Unpin for Iter<'a, T> where &'a Receiver<T>: Unpin,

impl<'a, T> UnsafeUnpin for Iter<'a, T> where &'a Receiver<T>: UnsafeUnpin,

impl<'a, T> UnwindSafe for Iter<'a, T> where &'a Receiver<T>: UnwindSafe,

Blanket Implementations

impl<I> IntoIterator for Iter<'a, T> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for Iter<'a, T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Iter<'a, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Iter<'a, T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

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

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Iter<'a, T> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

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

impl<T, U> Into<U> for Iter<'a, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Iter<'a, T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Iter<'a, T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>