From c92b7760bfe7f5aeb223798107202a3b8282fcd9 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 11 May 2020 18:20:52 +0800 Subject: [PATCH] chore: remove useless Box in Task --- napi/src/executor.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/napi/src/executor.rs b/napi/src/executor.rs index b4c3335a..8b781522 100644 --- a/napi/src/executor.rs +++ b/napi/src/executor.rs @@ -58,11 +58,11 @@ pub fn execute>( &UV_ASYNC_V_TABLE, )); let context = Context::from_waker(&waker); - let mut task = Box::new(Task { + let mut task = Task { future: Box::pin(future), context, - }); - if !task.as_mut().poll_future() { + }; + if !task.poll_future() { let arc_task = Arc::new(task); sys::uv_handle_set_data( uv_async_t_ref as *mut _ as *mut sys::uv_handle_t, @@ -83,7 +83,7 @@ impl<'a> Task<'a> { } unsafe extern "C" fn poll_future(handle: *mut sys::uv_async_t) { - let data_ptr = sys::uv_handle_get_data(handle as *mut sys::uv_handle_t) as *mut Box; + let data_ptr = sys::uv_handle_get_data(handle as *mut sys::uv_handle_t) as *mut Task; let mut task = Arc::from_raw(data_ptr); if let Some(mut_task) = Arc::get_mut(&mut task) { if mut_task.poll_future() {