Crates.io | async-select-all |
lib.rs | async-select-all |
version | 0.1.0 |
source | src |
created_at | 2020-11-30 02:57:51.285332 |
updated_at | 2020-11-30 02:57:51.285332 |
description | A futures library adapter for selecting over a list of futures. |
homepage | https://github.com/cod-technologies/async-select-all |
repository | https://github.com/cod-technologies/async-select-all.git |
max_upload_size | |
id | 318070 |
size | 18,732 |
A futures library adapter for selecting over a list of futures.
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]);
}
async-select-all
works on rust 1.37 or later.
This project is licensed under the Apache-2.0 license (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).
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.