async-select-all

Crates.ioasync-select-all
lib.rsasync-select-all
version0.1.0
sourcesrc
created_at2020-11-30 02:57:51.285332
updated_at2020-11-30 02:57:51.285332
descriptionA futures library adapter for selecting over a list of futures.
homepagehttps://github.com/cod-technologies/async-select-all
repositoryhttps://github.com/cod-technologies/async-select-all.git
max_upload_size
id318070
size18,732
David  Li (davidli2010)

documentation

https://docs.rs/async-select-all/

README

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.

Commit count: 4

cargo fmt