use Poll;
use task;
mod option;
pub use self::option::FutureOption;
#[path = "result.rs"]
mod result_;
pub use self::result_::{result, ok, err, FutureResult};
#[cfg(feature = "either")]
mod either;
pub trait Future {
type Item;
type Error;
fn poll(&mut self, cx: &mut task::Context) -> Poll<Self::Item, Self::Error>;
}
impl<'a, F: ?Sized + Future> Future for &'a mut F {
type Item = F::Item;
type Error = F::Error;
fn poll(&mut self, cx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
(**self).poll(cx)
}
}
if_std! {
impl<F: ?Sized + Future> Future for ::std::boxed::Box<F> {
type Item = F::Item;
type Error = F::Error;
fn poll(&mut self, cx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
(**self).poll(cx)
}
}
#[cfg(feature = "nightly")]
impl<F: ?Sized + Future> Future for ::std::boxed::PinBox<F> {
type Item = F::Item;
type Error = F::Error;
fn poll(&mut self, cx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
unsafe { ::core::mem::Pin::get_mut(&mut self.as_pin()).poll(cx) }
}
}
impl<F: Future> Future for ::std::panic::AssertUnwindSafe<F> {
type Item = F::Item;
type Error = F::Error;
fn poll(&mut self, cx: &mut task::Context) -> Poll<F::Item, F::Error> {
self.0.poll(cx)
}
}
}
pub trait IntoFuture {
type Future: Future<Item=Self::Item, Error=Self::Error>;
type Item;
type Error;
fn into_future(self) -> Self::Future;
}
impl<F> IntoFuture for F where F: Future {
type Future = Self;
type Item = <Self as Future>::Item;
type Error = <Self as Future>::Error;
fn into_future(self) -> Self { self }
}