Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub trait Future {
fn boxed(self) -> BoxFuture<Self::Item, Self::Error>
where Self: Sized + Send + 'static
{
::std::boxed::Box::new(self)
Boxed::boxed(self)
}

/// Map this future's result to a different type, returning a new future of
Expand Down Expand Up @@ -1044,3 +1044,19 @@ impl<F> fmt::Debug for ExecuteError<F> {
}
}
}

trait Boxed: Future {
fn boxed(self) -> BoxFuture<Self::Item, Self::Error>;
}

impl<F> Boxed for F where F: Future + Sized + Send + 'static {
default fn boxed(self) -> BoxFuture<Self::Item, Self::Error> {
::std::boxed::Box::new(self)
}
}

impl<I, E> Boxed for BoxFuture<I, E> {
fn boxed(self) -> BoxFuture<Self::Item, Self::Error> {
self
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
#![no_std]
#![deny(missing_docs, missing_debug_implementations)]
#![doc(html_root_url = "https://docs.rs/futures/0.1")]
#![feature(specialization)]

#[macro_use]
#[cfg(feature = "use_std")]
Expand Down