pub fn sorted_channel<T>() -> (Sender<T>, Receiver<T>)
Expand description
Creates a new sorted channel returning the Sender
/Receiver
halves.
ยงExamples
use sorted_channel::sorted_channel;
use std::thread;
let (tx, rx) = sorted_channel();
let handle = thread::spawn(move || {
for i in [0, 9, 1, 8, 2, 7, 3, 6, 4, 5] {
tx.send(i).unwrap();
}
});
handle.join().unwrap();
for i in (0..10).rev() {
assert_eq!(rx.recv(), Ok(i));
}