Clarify vec docs on deallocation (fixes #46879) by Manishearth · Pull Request #46884 · rust-lang/rust (original) (raw)
New issue
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation6 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
| /// details are very subtle — if you intend to allocate memory using a `Vec` |
|---|
| /// and use it for something else (either to pass to unsafe code, or to build your |
| /// own memory-backed collection), be sure to deallocate this memory by using |
| /// `from_raw_parts` to recover the `Vec` and then dropping it. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a newb this is confusing. Maybe an explicit inline example would be good.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that might derail the docs; this is about the usage of vec in unsafe contexts and we don't want to go too deep in the weeds there.
(also, this paragraph is related to advanced usage of rust anyway)
“to recover the Vec and then dropping it” sounds weird but I don’t know if “drop it” is grammatically correct either
@bors: r+ rollup
@tinaun it doesn't sound odd to me; we might be able to simplify it by splitting the sentences up a bit, but this is good enough to fix the bug, imo.
📌 Commit 52c28ff has been approved by steveklabnik
kennytm added a commit to kennytm/rust that referenced this pull request
bors added a commit that referenced this pull request
Rollup of 14 pull requests
- Successful merges: #46636, #46780, #46784, #46809, #46814, #46820, #46839, #46847, #46858, #46878, #46884, #46890, #46898, #46918
- Failed merges: