diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2018-07-26 09:18:34 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-26 09:18:34 -0600 |
| commit | 7c09bab986086b19bae6afe342737578357fbe86 (patch) | |
| tree | a13047e5fbbc1c108e6b59ee071df6c6e54b4695 /src/liballoc | |
| parent | 007177c445f3e56f891245ad1a68f0041310efb4 (diff) | |
| parent | 75d22263c92c28510a1bff2a91031d28817443d8 (diff) | |
| download | rust-7c09bab986086b19bae6afe342737578357fbe86.tar.gz rust-7c09bab986086b19bae6afe342737578357fbe86.zip | |
Rollup merge of #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>
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 6d3bc6e79b5..2cf9b13a67a 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -67,7 +67,7 @@ use core::marker::{Unpin, Unsize}; use core::mem::{self, PinMut}; use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState}; use core::ptr::{self, NonNull, Unique}; -use core::task::{Context, Poll}; +use core::task::{Context, Poll, Executor, SpawnErrorKind, SpawnObjError}; use raw_vec::RawVec; use str::from_boxed_utf8_unchecked; @@ -973,6 +973,19 @@ unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinBox<F> } #[unstable(feature = "futures_api", issue = "50547")] +impl<E> Executor for Box<E> + where E: Executor + ?Sized +{ + fn spawn_obj(&mut self, task: FutureObj<'static, ()>) -> Result<(), SpawnObjError> { + (**self).spawn_obj(task) + } + + fn status(&self) -> Result<(), SpawnErrorKind> { + (**self).status() + } +} + +#[unstable(feature = "futures_api", issue = "50547")] impl<'a, F: Future<Output = ()> + Send + 'a> From<PinBox<F>> for FutureObj<'a, ()> { fn from(boxed: PinBox<F>) -> Self { FutureObj::new(boxed) |
