#async #future #select #all

async-select-all

A futures library adapter for selecting over a list of futures

1 unstable release

0.1.0 Nov 30, 2020

#280 in Asynchronous

Apache-2.0

7KB
76 lines

async-select-all

Apache-2.0 licensed Minimum rustc version Crate API

A futures library adapter for selecting over a list of futures.

Usage

use async_select_all::SelectAll;
use futures::executor::block_on;

async fn inc(i: i32) -> i32 {
    i + 1
}

fn main() {
    let futures = vec![inc(10), inc(5)];
    let mut select_all = SelectAll::from(futures);
    let vec = block_on(async {
        let mut vec = Vec::with_capacity(select_all.len());
        while !select_all.is_empty() {
            let val = select_all.select().await;
            vec.push(val)
        }
        vec.sort();
        vec
    });
    assert_eq!(vec, vec![6, 11]);
}

Rust version requirements

async-select-all works on rust 1.37 or later.

License

This project is licensed under the Apache-2.0 license (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in async-select-all by you, shall be licensed as Apache-2.0, without any additional terms or conditions.

Dependencies

~56KB