Function promising_future::any [] [src]

pub fn any<T, I>(futures: I) -> Option<T> where I: IntoIterator<Item=Future<T>>, T: Send

Return first available Future from an iterator of Futures.

Given an iterator producing a stream of Future<T> values, return the first resolved value. All other values are discarded. Futures which resolve without values are ignored.

Note 1: This lazily consumes the input iterator so it can be infinite. However each unresolved Future takes memory so Futures should resolve in bounded time (they need not resolve with values; valueless Futures are discarded).

Note 2: futures.into_iter() should avoid blocking, as that will block this function even if other Futures resolve. (FIXME)