mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
test: remove unnecessary unsafe code (#2424)
This commit is contained in:
parent
43bbbf61a2
commit
7e88b56be5
@ -119,20 +119,16 @@ impl<T: Stream> Spawn<T> {
|
|||||||
impl<T: Future> Future for Spawn<T> {
|
impl<T: Future> Future for Spawn<T> {
|
||||||
type Output = T::Output;
|
type Output = T::Output;
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
// Safety: we only expose &mut T if T: Unpin therefore this is safe.
|
self.future.as_mut().poll(cx)
|
||||||
let future = unsafe { self.map_unchecked_mut(|s| &mut s.future) };
|
|
||||||
future.poll(cx)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Stream> Stream for Spawn<T> {
|
impl<T: Stream> Stream for Spawn<T> {
|
||||||
type Item = T::Item;
|
type Item = T::Item;
|
||||||
|
|
||||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
// Safety: we only expose &mut T if T: Unpin therefore this is safe.
|
self.future.as_mut().poll_next(cx)
|
||||||
let stream = unsafe { self.map_unchecked_mut(|s| &mut s.future) };
|
|
||||||
stream.poll_next(cx)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user