Skip to content

Commit 7c09bab

Browse files
Rollup merge of rust-lang#52674 - tinaun:patch-2, r=cramertj
Impl Executor for Box<E: Executor> removes the need for the compatibility lib between futures 0.1 and 0.3 to use a wrapper type to implement Executor for Box<Executor>
2 parents 007177c + 75d2226 commit 7c09bab

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/liballoc/boxed.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use core::marker::{Unpin, Unsize};
6767
use core::mem::{self, PinMut};
6868
use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState};
6969
use core::ptr::{self, NonNull, Unique};
70-
use core::task::{Context, Poll};
70+
use core::task::{Context, Poll, Executor, SpawnErrorKind, SpawnObjError};
7171

7272
use raw_vec::RawVec;
7373
use str::from_boxed_utf8_unchecked;
@@ -972,6 +972,19 @@ unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinBox<F>
972972
}
973973
}
974974

975+
#[unstable(feature = "futures_api", issue = "50547")]
976+
impl<E> Executor for Box<E>
977+
where E: Executor + ?Sized
978+
{
979+
fn spawn_obj(&mut self, task: FutureObj<'static, ()>) -> Result<(), SpawnObjError> {
980+
(**self).spawn_obj(task)
981+
}
982+
983+
fn status(&self) -> Result<(), SpawnErrorKind> {
984+
(**self).status()
985+
}
986+
}
987+
975988
#[unstable(feature = "futures_api", issue = "50547")]
976989
impl<'a, F: Future<Output = ()> + Send + 'a> From<PinBox<F>> for FutureObj<'a, ()> {
977990
fn from(boxed: PinBox<F>) -> Self {

0 commit comments

Comments
 (0)