We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The docs for these are currently fairly meagre:
unsafe fn from_raw_parts(buf: *mut u8, length: usize, capacity: usize) -> String Creates a new String from a length, capacity, and pointer. This is unsafe because: We call Vec::from_raw_parts to get a Vec<u8>; We assume that the Vec contains valid UTF-8. unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Vec Creates a Vec<T> directly from the raw components of another vector. This is highly unsafe, due to the number of invariants that aren't checked.
unsafe fn from_raw_parts(buf: *mut u8, length: usize, capacity: usize) -> String
Creates a new String from a length, capacity, and pointer.
This is unsafe because:
Vec::from_raw_parts
Vec<u8>
unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Vec
Creates a Vec<T> directly from the raw components of another vector.
Vec<T>
This is highly unsafe, due to the number of invariants that aren't checked.
They need to be more specific about the details, e.g.:
ptr
String
Vec
capacity
Violating these may cause problems like corrupting the allocators internal datastructures.
The text was updated successfully, but these errors were encountered:
Add more description for from_raw_parts's unsafety
57eed53
Fixes rust-lang#26737.
Auto merge of #26740 - steveklabnik:gh26737, r=gankro
4c246ec
Fixes #26737.
No branches or pull requests
The docs for these are currently fairly meagre:
They need to be more specific about the details, e.g.:
ptr
needs to have been previously allocated viaString
/Vec
(at least, it's highly likely to be incorrect if it wasn't)capacity
needs to be the capacity that the pointer was allocated with.Violating these may cause problems like corrupting the allocators internal datastructures.
The text was updated successfully, but these errors were encountered: