aboutsummaryrefslogtreecommitdiff
path: root/tests/test_bytes.rs
diff options
context:
space:
mode:
authorGravatar Erick Tryzelaar <erick.tryzelaar@gmail.com> 2022-05-10 05:22:19 -0400
committerGravatar GitHub <noreply@github.com> 2022-05-10 11:22:19 +0200
commitb8d27c016f53f0c1fea920223bc5a92f329d47df (patch)
tree805fc151dddb71d191a41e4baa52a2fd99e80508 /tests/test_bytes.rs
parent0ce4fe3c91f0d008674869348ffd804b78846eca (diff)
downloadbytes-b8d27c016f53f0c1fea920223bc5a92f329d47df.tar.gz
bytes-b8d27c016f53f0c1fea920223bc5a92f329d47df.tar.zst
bytes-b8d27c016f53f0c1fea920223bc5a92f329d47df.zip
Add `UninitSlice::as_uninit_slice_mut()` (#548)
This adds an unsafe method to convert a `&mut UninitSlice` into a `&mut [MaybeUninit<u8>]`. This method is unsafe because some of the bytes in the slice may be initialized, and the caller should not overwrite them with uninitialized bytes. This came about when auditing [tokio-util's udp frame], where they want to pass the unitialized portion of a `BytesMut` to [ReadBuf::uninit]. They need to do this unsafe pointer casting in a few places, which complicates audits. This method lets us document the safety invariants the caller needs to maintain when doing this conversion. [tokio-util's udp frame]: https://github.com/tokio-rs/tokio/blob/master/tokio-util/src/udp/frame.rs#L87 [ReadBuf::uninit]: https://docs.rs/tokio/latest/tokio/io/struct.ReadBuf.html#method.uninit
Diffstat (limited to 'tests/test_bytes.rs')
0 files changed, 0 insertions, 0 deletions