clarify alignment requirements in Vec::from_raw_parts
This commit is contained in:
parent
b961a03060
commit
0edc90cd18
1 changed files with 5 additions and 1 deletions
|
@ -404,7 +404,10 @@ impl<T> Vec<T> {
|
|||
///
|
||||
/// * `ptr` needs to have been previously allocated via [`String`]/`Vec<T>`
|
||||
/// (at least, it's highly likely to be incorrect if it wasn't).
|
||||
/// * `ptr`'s `T` needs to have the same size and alignment as it was allocated with.
|
||||
/// * `T` needs to have the same size and alignment as what `ptr` was allocated with.
|
||||
/// (`T` having a less strict alignment is not sufficient, the alignment really
|
||||
/// needs to be equal to satsify the [`dealloc`] requirement that memory must be
|
||||
/// allocated and deallocated with the same layout.)
|
||||
/// * `length` needs to be less than or equal to `capacity`.
|
||||
/// * `capacity` needs to be the capacity that the pointer was allocated with.
|
||||
///
|
||||
|
@ -423,6 +426,7 @@ impl<T> Vec<T> {
|
|||
/// function.
|
||||
///
|
||||
/// [`String`]: ../../std/string/struct.String.html
|
||||
/// [`dealloc`]: ../../alloc/alloc/trait.GlobalAlloc.html#tymethod.dealloc
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue