Skip to content

Commit 75d2226

Browse files
committed
Impl Executor for Box<E: Executor>
1 parent f498e4e commit 75d2226

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/liballoc/boxed.rs

+14-1
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)