// run-pass use std::marker; use std::mem; fn main() { let workers = (0..0).map(|_| result::()); drop(join_all(workers).poll()); } trait Future { type Item; type Error; fn poll(&mut self) -> Result; } trait IntoFuture { type Future: Future; type Item; type Error; fn into_future(self) -> Self::Future; } impl IntoFuture for F { type Future = F; type Item = F::Item; type Error = F::Error; fn into_future(self) -> F { self } } struct FutureResult { _inner: marker::PhantomData<(T, E)>, } fn result() -> FutureResult { loop {} } impl Future for FutureResult { type Item = T; type Error = E; fn poll(&mut self) -> Result { loop {} } } struct JoinAll where I: IntoIterator, I::Item: IntoFuture, { elems: Vec<::Item>, } fn join_all(_: I) -> JoinAll where I: IntoIterator, I::Item: IntoFuture, { JoinAll { elems: vec![] } } impl Future for JoinAll where I: IntoIterator, I::Item: IntoFuture, { type Item = Vec<::Item>; type Error = ::Error; fn poll(&mut self) -> Result { let elems = mem::replace(&mut self.elems, Vec::new()); Ok(elems.into_iter().map(|e| { e }).collect::>()) } }