diff options
| author | Josef Reinhard Brandl <mail@josefbrandl.de> | 2018-06-30 17:26:38 +0200 |
|---|---|---|
| committer | Josef Reinhard Brandl <mail@josefbrandl.de> | 2018-07-02 13:59:39 +0200 |
| commit | 3d43f828f5f1261b88f00582074f6cd021f31614 (patch) | |
| tree | baff884a7b3e9f15880ac44867bb1016eea7f56f /src/liballoc | |
| parent | a96c88e80fce9d1950aa4700bdeacee35cb9ac02 (diff) | |
| download | rust-3d43f828f5f1261b88f00582074f6cd021f31614.tar.gz rust-3d43f828f5f1261b88f00582074f6cd021f31614.zip | |
Make custom trait object for `Future` generic
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 6a05ef68088..c1778ef101a 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -66,7 +66,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, UnsafeTask, TaskObj, LocalTaskObj}; +use core::task::{Context, Poll, UnsafeFutureObj, FutureObj, LocalFutureObj}; use core::convert::From; use raw_vec::RawVec; @@ -933,12 +933,12 @@ impl<'a, F: ?Sized + Future> Future for PinBox<F> { } #[unstable(feature = "futures_api", issue = "50547")] -unsafe impl<F: Future<Output = ()> + 'static> UnsafeTask for PinBox<F> { +unsafe impl<T, F: Future<Output = T> + 'static> UnsafeFutureObj<T> for PinBox<F> { fn into_raw(self) -> *mut () { PinBox::into_raw(self) as *mut () } - unsafe fn poll(task: *mut (), cx: &mut Context) -> Poll<()> { + unsafe fn poll(task: *mut (), cx: &mut Context) -> Poll<T> { let ptr = task as *mut F; let pin: PinMut<F> = PinMut::new_unchecked(&mut *ptr); pin.poll(cx) @@ -950,29 +950,29 @@ unsafe impl<F: Future<Output = ()> + 'static> UnsafeTask for PinBox<F> { } #[unstable(feature = "futures_api", issue = "50547")] -impl<F: Future<Output = ()> + Send + 'static> From<PinBox<F>> for TaskObj { - fn from(boxed: PinBox<F>) -> Self { - TaskObj::new(boxed) +impl<T, F: Future<Output = T> + Send + 'static> Into<FutureObj<T>> for PinBox<F> { + fn into(self) -> FutureObj<T> { + FutureObj::new(self) } } #[unstable(feature = "futures_api", issue = "50547")] -impl<F: Future<Output = ()> + Send + 'static> From<Box<F>> for TaskObj { - fn from(boxed: Box<F>) -> Self { - TaskObj::new(PinBox::from(boxed)) +impl<T, F: Future<Output = T> + Send + 'static> Into<FutureObj<T>> for Box<F> { + fn into(self) -> FutureObj<T> { + FutureObj::new(PinBox::from(self)) } } #[unstable(feature = "futures_api", issue = "50547")] -impl<F: Future<Output = ()> + 'static> From<PinBox<F>> for LocalTaskObj { - fn from(boxed: PinBox<F>) -> Self { - LocalTaskObj::new(boxed) +impl<T, F: Future<Output = T> + 'static> Into<LocalFutureObj<T>> for PinBox<F> { + fn into(self) -> LocalFutureObj<T> { + LocalFutureObj::new(self) } } #[unstable(feature = "futures_api", issue = "50547")] -impl<F: Future<Output = ()> + 'static> From<Box<F>> for LocalTaskObj { - fn from(boxed: Box<F>) -> Self { - LocalTaskObj::new(PinBox::from(boxed)) +impl<T, F: Future<Output = T> + 'static> Into<LocalFutureObj<T>> for Box<F> { + fn into(self) -> LocalFutureObj<T> { + LocalFutureObj::new(PinBox::from(self)) } } |
