summaryrefslogtreecommitdiffstats
path: root/third_party/rust/cc/src/parallel/mod.rs
blob: d69146dc59a1e3458502cb4d8796b24ca5ac2d94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
        }
    }
}