From 3d43f828f5f1261b88f00582074f6cd021f31614 Mon Sep 17 00:00:00 2001 From: Josef Reinhard Brandl Date: Sat, 30 Jun 2018 17:26:38 +0200 Subject: Make custom trait object for `Future` generic --- src/liballoc/boxed.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/liballoc') 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 { } #[unstable(feature = "futures_api", issue = "50547")] -unsafe impl + 'static> UnsafeTask for PinBox { +unsafe impl + 'static> UnsafeFutureObj for PinBox { 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 { let ptr = task as *mut F; let pin: PinMut = PinMut::new_unchecked(&mut *ptr); pin.poll(cx) @@ -950,29 +950,29 @@ unsafe impl + 'static> UnsafeTask for PinBox { } #[unstable(feature = "futures_api", issue = "50547")] -impl + Send + 'static> From> for TaskObj { - fn from(boxed: PinBox) -> Self { - TaskObj::new(boxed) +impl + Send + 'static> Into> for PinBox { + fn into(self) -> FutureObj { + FutureObj::new(self) } } #[unstable(feature = "futures_api", issue = "50547")] -impl + Send + 'static> From> for TaskObj { - fn from(boxed: Box) -> Self { - TaskObj::new(PinBox::from(boxed)) +impl + Send + 'static> Into> for Box { + fn into(self) -> FutureObj { + FutureObj::new(PinBox::from(self)) } } #[unstable(feature = "futures_api", issue = "50547")] -impl + 'static> From> for LocalTaskObj { - fn from(boxed: PinBox) -> Self { - LocalTaskObj::new(boxed) +impl + 'static> Into> for PinBox { + fn into(self) -> LocalFutureObj { + LocalFutureObj::new(self) } } #[unstable(feature = "futures_api", issue = "50547")] -impl + 'static> From> for LocalTaskObj { - fn from(boxed: Box) -> Self { - LocalTaskObj::new(PinBox::from(boxed)) +impl + 'static> Into> for Box { + fn into(self) -> LocalFutureObj { + LocalFutureObj::new(PinBox::from(self)) } } -- cgit 1.4.1-3-g733a5