Skip to content

Commit cb04126

Browse files
committed
move retain_unordered_mut function into parallel module
1 parent 6320cf3 commit cb04126

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/lib.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ impl Build {
13751375

13761376
cell_update(&pendings, |mut pendings| {
13771377
// Try waiting on them.
1378-
retain_unordered_mut(&mut pendings, |(cmd, program, child, _token)| {
1378+
parallel::retain_unordered_mut(&mut pendings, |(cmd, program, child, _token)| {
13791379
match try_wait_on_child(cmd, program, &mut child.0, &mut stdout) {
13801380
Ok(Some(())) => {
13811381
// Task done, remove the entry
@@ -4344,21 +4344,3 @@ impl Drop for PrintThread {
43444344
self.handle.take().unwrap().join().unwrap();
43454345
}
43464346
}
4347-
4348-
/// Remove all element in `vec` which `f(element)` returns `false`.
4349-
///
4350-
/// TODO: Remove this once the MSRV is bumped to v1.61
4351-
#[cfg(feature = "parallel")]
4352-
fn retain_unordered_mut<T, F>(vec: &mut Vec<T>, mut f: F)
4353-
where
4354-
F: FnMut(&mut T) -> bool,
4355-
{
4356-
let mut i = 0;
4357-
while i < vec.len() {
4358-
if f(&mut vec[i]) {
4359-
i += 1;
4360-
} else {
4361-
vec.swap_remove(i);
4362-
}
4363-
}
4364-
}

src/parallel/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
pub(crate) mod async_executor;
22
pub(crate) mod job_token;
3+
4+
/// Remove all element in `vec` which `f(element)` returns `false`.
5+
///
6+
/// TODO: Remove this once the MSRV is bumped to v1.61
7+
pub(crate) fn retain_unordered_mut<T, F>(vec: &mut Vec<T>, mut f: F)
8+
where
9+
F: FnMut(&mut T) -> bool,
10+
{
11+
let mut i = 0;
12+
while i < vec.len() {
13+
if f(&mut vec[i]) {
14+
i += 1;
15+
} else {
16+
vec.swap_remove(i);
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)