Pattern matching
use tokio::sync::mpsc;
#[tokio::main]
async fn main() {
let (mut tx1, mut rx1) = mpsc::channel(128);
let (mut tx2, mut rx2) = mpsc::channel(128);
// Do something w/ `tx1` and `tx2`
tokio::select! {
Some(v) = rx1.recv() => {
println!("Got {:?} from rx1", v);
}
println!("Got {:?} from rx2", v);
}
else => {
println!("Both channels closed");
}
}