-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Feature: more control over container (eg. Vec) capacities #49385
Copy link
Copy link
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Currently there is only one way to reduce the capacity of a
Vecwithout clearing it completely:vec.shrink_to_fit()However, often more control is needed. For example, it's common to want to shrink the capacity, but not below some threshold, eg.
vec.shrink_to(MIN_CAPACITY).There are probably other cases where you would want to be able to more directly control the capacity too.