diff options
Diffstat (limited to 'third_party/rust/cc/src/parallel/mod.rs')
-rw-r--r-- | third_party/rust/cc/src/parallel/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/third_party/rust/cc/src/parallel/mod.rs b/third_party/rust/cc/src/parallel/mod.rs new file mode 100644 index 0000000000..d69146dc59 --- /dev/null +++ b/third_party/rust/cc/src/parallel/mod.rs @@ -0,0 +1,20 @@ +pub(crate) mod async_executor; +pub(crate) mod job_token; +pub(crate) mod stderr; + +/// Remove all element in `vec` which `f(element)` returns `false`. +/// +/// TODO: Remove this once the MSRV is bumped to v1.61 +pub(crate) fn retain_unordered_mut<T, F>(vec: &mut Vec<T>, mut f: F) +where + F: FnMut(&mut T) -> bool, +{ + let mut i = 0; + while i < vec.len() { + if f(&mut vec[i]) { + i += 1; + } else { + vec.swap_remove(i); + } + } +} |