tinyvec icon indicating copy to clipboard operation
tinyvec copied to clipboard

`drain_filter`

Open Lokathor opened this issue 4 years ago • 2 comments

  • [ ] ArrayVec
  • [ ] TinyVec

Waiting on https://github.com/rust-lang/rust/issues/43244, though we could add this behind a feature gate before that if we like.

Lokathor avatar Jan 24 '20 08:01 Lokathor

You don't strictly need to wait for nightly to do this, for the Vec side of things (unless the feature is enabled) you could simply use the "manual" version of .drain_filter()

let mut idx = 0;
while idx < vec.get().len() {
    if vec[idx] == input {
        vec.remove(idx);
    } else {
        idx += 1;
    }
}

Kixiron avatar Oct 24 '21 16:10 Kixiron

In case of TinyVec, drain_filter = partition + drain(partition_point..)

Soveu avatar Oct 24 '21 19:10 Soveu