Pattern matching

    1. use tokio::sync::mpsc;
    2. #[tokio::main]
    3. async fn main() {
    4. let (mut tx1, mut rx1) = mpsc::channel(128);
    5. let (mut tx2, mut rx2) = mpsc::channel(128);
    6. // Do something w/ `tx1` and `tx2`
    7. tokio::select! {
    8. Some(v) = rx1.recv() => {
    9. println!("Got {:?} from rx1", v);
    10. }
    11. println!("Got {:?} from rx2", v);
    12. }
    13. else => {
    14. println!("Both channels closed");
    15. }
    16. }