]> git.lizzy.rs Git - rust.git/commit
Docs: make Vec::from_raw_parts documentation less strict
authorJP Posma <janpaul123@users.noreply.github.com>
Wed, 16 Mar 2022 16:34:12 +0000 (09:34 -0700)
committerGitHub <noreply@github.com>
Wed, 16 Mar 2022 16:34:12 +0000 (09:34 -0700)
commit80340f62fee46c1ac5ea787e4dcbe553c6abd41a
tree7256127b11375cf0bd94324fa5862cd48035b7eb
parent461e8078010433ff7de2db2aaae8a3cfb0847215
Docs: make Vec::from_raw_parts documentation less strict

This is my first PR; be gentle!

In https://users.rust-lang.org/t/why-does-vec-from-raw-parts-require-same-size-and-not-same-size-capacity/73036/2?u=janpaul123 it was suggested to me that I should make a PR to make the documentation of `Vec::from_raw_parts` less strict, since we don't require `T` to have the same size, just `size_of::<T>() * capacity` to be the same, since that is what results in `Layout::size` being the same in `dealloc`, which is really what matters.

Also in https://users.rust-lang.org/t/why-does-vec-from-raw-parts-require-same-size-and-not-same-size-capacity/73036/8?u=janpaul123 it was suggested that it's better to use `slice::from_raw_parts`, which I think is useful advise that could also be mentioned in the docs, so I added that too.

Let me know what you think! :)
library/alloc/src/vec/mod.rs