mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-20 00:00:10 +02:00
Add a safe way to create UninitSlice from slices (#598)
Introduce UninitSlice::from_slice and UninitSlice::from_uninit_slice methods which safely create Uninit slice from provided slice of maybe uninitialised or initialised memory. In addition, add `From<&mut [T]>` implementations (for `T=u8` and `T=MaybeUninit<u8>`) which do conversion from slice to UninitSlice. Closes: #552
This commit is contained in:
+1
-1
@@ -1102,7 +1102,7 @@ unsafe impl BufMut for BytesMut {
|
||||
if self.capacity() == self.len() {
|
||||
self.reserve(64);
|
||||
}
|
||||
UninitSlice::from_slice(self.spare_capacity_mut())
|
||||
self.spare_capacity_mut().into()
|
||||
}
|
||||
|
||||
// Specialize these methods so they can skip checking `remaining_mut`
|
||||
|
||||
Reference in New Issue
Block a user