Add sound implementation of Bytes for &[u8] #308
Copy link
Copy link
Closed
Labels
enhancementAn improvement of the API.An improvement of the API.priority:mediumMedium priority issue.Medium priority issue.
Milestone
Description
See rust-lang/rfcs#2930 (comment) and rust-lang/rfcs#2930 (comment).
Example:
let mut buf = [0u8];
let maybe = unsafe { &mut *((&mut buf) as *mut [u8] as *mut [MaybeUninit<u8>]) };
// After this line `buf` will contain uninitialized value, which is UB
maybe[0] = MaybeUninit::uninit();Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementAn improvement of the API.An improvement of the API.priority:mediumMedium priority issue.Medium priority issue.
Activity
Remove unsound implementation of Bytes for slices and arrays
Thomasdezeeuw commentedon Oct 18, 2020
This should also revert all the changes in the tests/docs from 4f8731c.
[-]Bytes::as_bytes implementation for &[u8] is unsound[/-][+]Add sound implementation of Bytes for &[u8][/+]Thomasdezeeuw commentedon Nov 23, 2020
Changing to issue to track adding back an implementation of
Bytesfor&[u8].