From 32e1537df264e27f2ef0efd128a6c32f3a395459 Mon Sep 17 00:00:00 2001 From: xuanyuan300 Date: Sat, 9 Dec 2023 23:11:51 +0800 Subject: [PATCH] fix cargo clippy Signed-off-by: xuanyuan300 --- lib/wasix/src/runtime/task_manager/tokio.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/wasix/src/runtime/task_manager/tokio.rs b/lib/wasix/src/runtime/task_manager/tokio.rs index ceee20435d9..6118717b7b8 100644 --- a/lib/wasix/src/runtime/task_manager/tokio.rs +++ b/lib/wasix/src/runtime/task_manager/tokio.rs @@ -123,7 +123,7 @@ impl VirtualTaskManager for TokioTaskManager { .enter(handle, time) .await .ok() - .unwrap_or_else(|| ()) + .unwrap_or(()) }) } @@ -208,6 +208,7 @@ impl VirtualTaskManager for TokioTaskManager { } // Used by [`VirtualTaskManager::sleep_now`] to abort a sleep task when drop. +#[derive(Default)] struct SleepNow { abort_handle: Option, } @@ -230,14 +231,10 @@ impl SleepNow { } } -impl Default for SleepNow { - fn default() -> Self { - Self { abort_handle: None } - } -} - impl Drop for SleepNow { fn drop(&mut self) { - self.abort_handle.as_ref().map(|h| h.abort()); + if let Some(h) = self.abort_handle.as_ref() { + h.abort() + } } }