From 6b6e76080afc92450238df69c4edc12ee5f7518d Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 12 Jun 2020 19:49:39 +0900 Subject: chore: reduce pin related unsafe code (#2613) --- tokio-test/src/task.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'tokio-test/src') diff --git a/tokio-test/src/task.rs b/tokio-test/src/task.rs index 82d29134..728117cc 100644 --- a/tokio-test/src/task.rs +++ b/tokio-test/src/task.rs @@ -46,21 +46,11 @@ const SLEEP: usize = 2; impl Spawn { /// Consumes `self` returning the inner value - pub fn into_inner(mut self) -> T + pub fn into_inner(self) -> T where T: Unpin, { - drop(self.task); - - // Pin::into_inner is unstable, so we work around it - // - // Safety: `T` is bound by `Unpin`. - unsafe { - let ptr = Pin::get_mut(self.future.as_mut()) as *mut T; - let future = Box::from_raw(ptr); - mem::forget(self.future); - *future - } + *Pin::into_inner(self.future) } /// Returns `true` if the inner future has received a wake notification -- cgit v1.2.3