How do I conditionally return different types of futures?
Using async/await Since Rust 1.39, you can use async and await syntax to cover most cases: async fn a() -> usize { 2 } async fn b() -> usize { 10 } async fn f() -> usize { if 1 > 0 { a().await } else { b().await + 2 } } See also: What … Read more