-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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.
Description
Feature gate: #![feature(vec_push_within_capacity)]
This is a tracking issue for Vec::push_within_capacity
It enables pushing into a Vec if there is any capacity left and otherwise returns the value. I.e. it avoids implicit resizing. This can be useful when one wants to explicitly control it (e.g. via try_reserve
) or uses a Vec in an unsafe manner where moving the elements would be a problem.
Public API
// alloc::Vec
impl Vec<T, A> {
pub fn push_within_capacity(&mut self, value: T) -> Result<(), T>;
}
Steps / History
- Implementation: add Vec::push_within_capacity - fallible, does not allocate #89123
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- naming (e.g.
push_in_capacity
) - may become redundant due to larger-scale work in RFC: Add more support for fallible allocations in Vec rfcs#3271
Footnotes
elichai, I-code-stuff631, dullbananas, k12ish, xyangst and 5 more
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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.