diff options
author | Taiki Endo <te316e89@gmail.com> | 2020-06-12 19:49:39 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 19:49:39 +0900 |
commit | 6b6e76080afc92450238df69c4edc12ee5f7518d (patch) | |
tree | 9ce5f612595a3829778df524c24f51a91f155a0e /tokio-test | |
parent | 68b4ca9f553bd4c26ea78e1f564e452071cf6474 (diff) |
chore: reduce pin related unsafe code (#2613)
Diffstat (limited to 'tokio-test')
-rw-r--r-- | tokio-test/src/task.rs | 14 |
1 files changed, 2 insertions, 12 deletions
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<T> Spawn<T> { /// 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 |