Tracking Issue for Vec::pop_if · Issue #122741 · rust-lang/rust (original) (raw)

Feature gate: #![feature(vec_pop_if)]

This feature adds the Vec::pop_if method, which takes a predicate, evaluates it with the last element in the Vec if present, and returns the item if the predicate returns true. This makes it possible to conditionally remove the last element without the use of unwrap.

Public API

impl Vec { pub fn pop_if(&mut self, f: impl FnOnce(&mut T) -> bool) -> Option; }

Steps / History

Unresolved Questions

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html