pub struct Sender<T> { /* private fields */ }
Expand description
The sending-half of the sorted_channel
type. This sender can be cloned
and sent to multiple threads.
§Examples
use sorted_channel::sorted_channel;
use std::thread;
let (tx, rx) = sorted_channel();
let tx2 = tx.clone();
let h1 = thread::spawn(move || {
tx.send(2).unwrap();
tx.send(1).unwrap();
});
let h2 = thread::spawn(move || {
tx2.send(4).unwrap();
tx2.send(3).unwrap();
});
h1.join().unwrap();
h2.join().unwrap();
let outputs: Vec<_> = (0..4).map(|_| rx.recv().unwrap()).collect();
assert_eq!(outputs, [4, 3, 2, 1]);
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Sender<T>
impl<T> !RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T>where
T: Send,
impl<T> Sync for Sender<T>where
T: Send,
impl<T> Unpin for Sender<T>
impl<T> !UnwindSafe for Sender<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