Tracking Issue for vec::Drain{,Filter}::keep_rest
#101122
Labels
C-tracking-issue
Category: A tracking issue for an RFC or an unstable feature.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Feature gate:
#![feature(drain_keep_rest)]
This is a tracking issue for
vec::Drain{,Filter}::keep_rest
, methods allowing to keep elements in aVec
after draining some of them.Public API
Steps / History
vec::Drain{,Filter}::keep_rest
#95376Unresolved Questions
.drain_filter(f).take(N)
works as expectedDrop
forDrain
drain_filter
) then you'd need to write.foreach(drop)
to explicitly drop all the rest of the range that matches the filter.&mut self
instead ofself
?Drain
inside a struct and are operating on it from a&mut self
method of the struct,keep_rest(self)
is impossible to use. :(mem::replace(&mut self.drain_filter, Vec::new().drain(..)).keep_rest()
but the borrow checker won't like that.Drain
field toOption<Drain>
and useself.drain_filter.take().unwrap().keep_rest()
along withunwrap()
everywhere else that the drain is used. Not good..next()
returnsNone
.next()
panic!
s.keep_rest()
sets a flag inside theDrain
whichDrop
will use to decide its behavior, and you're free to continue accessing iterator elements in between.const EXHAUST_ON_DROP: bool = true
const generic parameter&mut Drain<'a, T, A, false>
from the beginningFootnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: