servo / rust-smallvec

"Small vector" optimization for Rust: store up to a small number of items on the stack
Apache License 2.0
1.36k stars 145 forks source link

Add `SmallVec::extract_if` to match `Vec::extract_if` #360

Open GnomedDev opened 1 month ago

GnomedDev commented 1 month ago

Currently, there exists the unstable Vec method extract_if which can be super useful. If this can be ported to SmallVec, that would be lovely and help with migration.

mbrubeck commented 1 month ago

Note: This is included in smallvec 2.0, which is currently available as a pre-release alpha version.

smallvec 1 has a similar method drain_filter which can be enabled using an optional Cargo feature:

https://docs.rs/smallvec/1/smallvec/index.html#drain_filter

(You can ignore the warning that the feature is unstable, since smallvec 1 is now in maintenance mode and will be receiving bug fixes only.)