pub struct Receiver<T> { /* private fields */ }
Expand description
The receiving-half of the sorted_channel
type. This receiver can be
cloned and sent to multiple threads. See Sender
for an example.
Implementations§
Source§impl<T> Receiver<T>
impl<T> Receiver<T>
Sourcepub fn recv(&self) -> Result<T, RecvError>
pub fn recv(&self) -> Result<T, RecvError>
Wait for data in the channel by blocking the current thread, returning
an error if there are no more Sender
s connected to this channel.
§Examples
use sorted_channel::sorted_channel;
use std::thread;
let (tx, rx) = sorted_channel();
thread::spawn(move || {
tx.send(7).unwrap();
});
assert_eq!(rx.recv(), Ok(7));
Failure from missing sender:
use sorted_channel::sorted_channel;
use std::thread;
let (tx, rx) = sorted_channel::<()>();
let handle = thread::spawn(move || {
drop(tx);
});
handle.join().unwrap();
assert!(rx.recv().is_err());
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Receiver<T>
impl<T> !RefUnwindSafe for Receiver<T>
impl<T> Send for Receiver<T>where
T: Send,
impl<T> Sync for Receiver<T>where
T: Send,
impl<T> Unpin for Receiver<T>
impl<T> !UnwindSafe for Receiver<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more