Skip to content

Commit

Permalink
refactor(h1): use UninitSlice::as_uninit_slice_mut() instead of cast
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Apr 3, 2024
1 parent 330ddf1 commit 8fc6cd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include = [
]

[dependencies]
bytes = "1"
bytes = "1.2"
http = "1"
http-body = "1"
tokio = { version = "1", features = ["sync"] }
Expand Down
6 changes: 3 additions & 3 deletions src/proto/h1/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::fmt;
#[cfg(feature = "server")]
use std::future::Future;
use std::io::{self, IoSlice};
use std::mem::MaybeUninit;
use std::pin::Pin;
use std::task::{Context, Poll};

Expand Down Expand Up @@ -246,8 +245,9 @@ where
self.read_buf.reserve(next);
}

let dst = self.read_buf.chunk_mut();
let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit<u8>]) };
// SAFETY: ReadBuf and poll_read promise not to set any uninitialized
// bytes onto `dst`.
let dst = unsafe { self.read_buf.chunk_mut().as_uninit_slice_mut() };
let mut buf = ReadBuf::uninit(dst);
match Pin::new(&mut self.io).poll_read(cx, buf.unfilled()) {
Poll::Ready(Ok(_)) => {
Expand Down

0 comments on commit 8fc6cd9

Please sign in to comment.