use std::error::Error;
use futures::{future, select}; // futures-0.3.1
use futures::executor::block_on;
fn main() -> Result<(), Box<dyn Error>> {
let ts: [(i32, i32); 3] = [(1, 10), (2, 20), (3, 30)];
for t in &ts {
let mut a = future::ready(t.0);
let mut b = future::pending::<()>();
block_on(async {
let got = select! {
got = a => got + t.1,
_ = b => 0,
};
eprintln!("got, t.0, t.1: {} {} {}", got, t.0, t.1);
})
}
Ok(())
}
Comments
0 B
|👍
/👎