Tracking Issue for `Vec::peek_mut`
Open
Nobody has claimed this yet.
C-tracking-issue
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(vec_peek_mut)]
This feature adds Vec::peek_mut, which returns a PeekMut struct. It is analogous to [BinaryHeap::peek_mut] and enables users to conditionally modify and remove the last element of a Vec without having to call unwrap.
Public API
impl<T> Vec<T> {
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T>>;
}
pub struct PeekMut<'a, T>;
impl<'a, T> PeekMut<'a, T> {
pub fn pop(self) -> T;
}
// impl `Deref`/`DerefMut` for `PeekMut`
Steps / History
- ACP: https://github.com/rust-lang/libs-team/issues/208
- Implementation: pending
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Should this be named
peekorpeek_mut?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the vec_peek_mut feature gate and compare the proposed Vec::peek_mut and PeekMut API with BinaryHeap::peek_mut. Review the linked ACP and resolve the naming question before implementing the pending API. Done means the implementation, FCP, and stabilization PR steps are completed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100