Skip to content

Clarify confusing wording on Vec #46879

Closed
@steveklabnik

Description

@steveklabnik

Originally reported here: https://news.ycombinator.com/item?id=15969317


I don't understand the following sentence:

... it is strongly recommended that you only free memory allocated by a Vec by creating a new Vec and dropping it.

Could someone parse this for me? To me, it reads like "to free memory allocated by a Vec v, create a new Vec w and drop it (i.e., w)".

This is obviously not what it is intended. What's the role of the second Vec? Is this only in a context where v is empty but its memory not yet freed? If so, why wouldn't shrink_to_fit work in that case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions