Closed
Description
The “Safety” section of the document of Vec::from_raw_parts
says:
length
needs to be less than or equal tocapacity
.capacity
needs to be the capacity that the pointer was allocated with.
I think the first requirement should also add “The first length
elements starting from ptr
are initialized”. And the second requirement could be relaxed into “capacity
needs to be less than or equal to the capacity that the pointer was allocated with”, this is because Allocator::deallocate
does not require specifying exact size that the pointer was allocated with.
Metadata
Metadata
Assignees
Labels
Area: Custom and system allocatorsArea: Documentation for any part of the project, including the compiler, standard library, and toolsCategory: This is a bug.Category: Discussion or questions that doesn't represent real issues.Relevant to the library API team, which will review and decide on the PR/issue.Relevant to the opsem team