Skip to content

Commit

Permalink
refactor: extract --jobserver-auth= to a free function
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo authored and petrochenkov committed Feb 5, 2024
1 parent d357534 commit dfa034f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,7 @@ impl Client {
}
};

let (arg, pos) = match ["--jobserver-fds=", "--jobserver-auth="]
.iter()
.map(|&arg| var.find(arg).map(|pos| (arg, pos)))
.find_map(|pos| pos)
{
let (arg, pos) = match find_jobserver_auth(var) {
Some((arg, pos)) => (arg, pos),
None => return FromEnv::new_err(FromEnvErrorInner::NoJobserver, env, var_os),
};
Expand Down Expand Up @@ -588,6 +584,13 @@ impl HelperState {
}
}

fn find_jobserver_auth(var: &str) -> Option<(&str, usize)> {
["--jobserver-fds=", "--jobserver-auth="]
.iter()
.map(|&arg| var.find(arg).map(|pos| (arg, pos)))
.find_map(|pos| pos)
}

#[test]
fn no_helper_deadlock() {
let x = crate::Client::new(32).unwrap();
Expand Down

0 comments on commit dfa034f

Please sign in to comment.