Skip to content

Commit

Permalink
fix(io): remove read_buf feature guard for poll_read_uninit
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Sep 24, 2024
1 parent 234df4c commit 22a9257
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions compio-io/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,16 @@ impl<S: crate::AsyncRead + 'static> AsyncStream<S> {
cx: &mut Context<'_>,
buf: &mut [MaybeUninit<u8>],
) -> Poll<io::Result<usize>> {
#[cfg(feature = "read_buf")]
{
let this = self.project();

let inner: &'static mut SyncStream<S> =
unsafe { &mut *(this.inner.get_unchecked_mut() as *mut _) };
poll_future_would_block!(
this.read_future,
cx,
inner.fill_read_buf(),
inner.read_buf_uninit(buf)
)
}
#[cfg(not(feature = "read_buf"))]
{
buf.fill(MaybeUninit::new(0));
self.poll_read(cx, unsafe {
std::slice::from_raw_parts_mut(buf.as_mut_ptr().cast(), buf.len())
})
}
let this = self.project();

let inner: &'static mut SyncStream<S> =
unsafe { &mut *(this.inner.get_unchecked_mut() as *mut _) };
poll_future_would_block!(
this.read_future,
cx,
inner.fill_read_buf(),
inner.read_buf_uninit(buf)
)
}
}

Expand Down

0 comments on commit 22a9257

Please sign in to comment.