1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
15 let workers
= (0..0).map(|_
| result
::<u32, ()>());
16 drop(join_all(workers
).poll());
23 fn poll(&mut self) -> Result
<Self::Item
, Self::Error
>;
27 type Future
: Future
<Item
=Self::Item
, Error
=Self::Error
>;
31 fn into_future(self) -> Self::Future
;
34 impl<F
: Future
> IntoFuture
for F
{
37 type Error
= F
::Error
;
39 fn into_future(self) -> F
{
44 struct FutureResult
<T
, E
> {
45 _inner
: marker
::PhantomData
<(T
, E
)>,
48 fn result
<T
, E
>() -> FutureResult
<T
, E
> {
52 impl<T
, E
> Future
for FutureResult
<T
, E
> {
56 fn poll(&mut self) -> Result
<T
, E
> {
62 where I
: IntoIterator
,
65 elems
: Vec
<<I
::Item
as IntoFuture
>::Item
>,
68 fn join_all
<I
>(_
: I
) -> JoinAll
<I
>
69 where I
: IntoIterator
,
72 JoinAll { elems: vec![] }
75 impl<I
> Future
for JoinAll
<I
>
76 where I
: IntoIterator
,
79 type Item
= Vec
<<I
::Item
as IntoFuture
>::Item
>;
80 type Error
= <I
::Item
as IntoFuture
>::Error
;
82 fn poll(&mut self) -> Result
<Self::Item
, Self::Error
> {
83 let elems
= mem
::replace(&mut self.elems
, Vec
::new());
84 Ok(elems
.into_iter().map(|e
| {
86 }).collect
::<Vec
<_
>>())