From f293c47c2fed3bc6fec0bba3e833ead654019f28 Mon Sep 17 00:00:00 2001 From: cactter Date: Fri, 22 Jul 2022 10:15:51 +0800 Subject: [PATCH] Shrink unsafe block --- tokio-native-tls/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tokio-native-tls/src/lib.rs b/tokio-native-tls/src/lib.rs index 8ce19c0..4cfcf79 100644 --- a/tokio-native-tls/src/lib.rs +++ b/tokio-native-tls/src/lib.rs @@ -120,14 +120,14 @@ where where F: FnOnce(&mut Context<'_>, Pin<&mut S>) -> Poll>, { - unsafe { + assert!(!self.context.is_null()); - let waker = &mut *(self.context as *mut _); + let waker = unsafe { &mut *(self.context as *mut _) }; match f(waker, Pin::new(&mut self.inner)) { Poll::Ready(r) => r, Poll::Pending => Err(io::Error::from(io::ErrorKind::WouldBlock)), } - } + } }