Type Definition unicycle::FuturesUnordered
source · [−]Expand description
A container for an unordered collection of Futures.
Examples
use tokio::time;
use std::time::Duration;
#[tokio::main]
async fn main() {
let mut futures = unicycle::FuturesUnordered::new();
futures.push(time::sleep(Duration::from_secs(2)));
futures.push(time::sleep(Duration::from_secs(3)));
futures.push(time::sleep(Duration::from_secs(1)));
while let Some(_) = futures.next().await {
println!("tick");
}
println!("done!");
}
Implementations
sourceimpl<T> FuturesUnordered<T>
impl<T> FuturesUnordered<T>
sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new, empty FuturesUnordered.
Examples
use unicycle::FuturesUnordered;
let mut futures = FuturesUnordered::new();
assert!(futures.is_empty());
futures.push(async { 42 });
Trait Implementations
sourceimpl<T> FromIterator<T> for FuturesUnordered<T> where
T: Future,
impl<T> FromIterator<T> for FuturesUnordered<T> where
T: Future,
sourcefn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more