Skip to content

Commit

Permalink
Rollup merge of rust-lang#52674 - tinaun:patch-2, r=cramertj
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark-Simulacrum authored Jul 26, 2018
2 parents 007177c + 75d2226 commit 7c09bab
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -972,6 +972,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 {
Expand Down

0 comments on commit 7c09bab

Please sign in to comment.