Skip to content

Commit

Permalink
chore: fixes new lint and format issues introduced in Rust 1.83
Browse files Browse the repository at this point in the history
  • Loading branch information
claymcleod committed Dec 4, 2024
1 parent 2812773 commit 59adfe3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 61 deletions.
2 changes: 1 addition & 1 deletion crankshaft-config/src/backend/generic/driver/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum Shell {
impl Shell {
/// Gets a series of args that can be passed through to a driver for
/// commands.
pub fn args<I, S>(&self, args: I) -> impl Iterator<Item = OsString>
pub fn args<I, S>(&self, args: I) -> impl Iterator<Item = OsString> + use<I, S>
where
I: IntoIterator<Item = OsString>,
{
Expand Down
63 changes: 33 additions & 30 deletions crankshaft-engine/src/service/runner/backend/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,38 +152,41 @@ impl crate::Backend for Backend {
let output = driver.run(submit).await.unwrap();

// (2) Monitoring the output.
if let Some(ref regex) = job_id_regex {
let stdout = String::from_utf8_lossy(&output.stdout);
let captures = regex.captures_iter(&stdout).next().unwrap_or_else(|| {
panic!(
"could not match the job id regex within stdout: `{}`",
stdout
)
});

// SAFETY: this will always unwrap, as the group is
// _required_ for the pattern to match.
let id = captures.get(1).map(|c| String::from(c.as_str())).unwrap();
subtitutions.insert(String::from("job_id"), id);

loop {
let monitor = config.resolve_monitor(&subtitutions).unwrap();
let output = driver.run(monitor).await.unwrap();

if !output.status.success() {
outputs.push(output);
break;
match job_id_regex {
Some(ref regex) => {
let stdout = String::from_utf8_lossy(&output.stdout);
let captures = regex.captures_iter(&stdout).next().unwrap_or_else(|| {
panic!(
"could not match the job id regex within stdout: `{}`",
stdout
)
});

// SAFETY: this will always unwrap, as the group is
// _required_ for the pattern to match.
let id = captures.get(1).map(|c| String::from(c.as_str())).unwrap();
subtitutions.insert(String::from("job_id"), id);

loop {
let monitor = config.resolve_monitor(&subtitutions).unwrap();
let output = driver.run(monitor).await.unwrap();

if !output.status.success() {
outputs.push(output);
break;
}

tokio::time::sleep(Duration::from_secs(
config
.monitor_frequency()
.unwrap_or(DEFAULT_MONITOR_FREQUENCY),
))
.await;
}

tokio::time::sleep(Duration::from_secs(
config
.monitor_frequency()
.unwrap_or(DEFAULT_MONITOR_FREQUENCY),
))
.await;
}
} else {
outputs.push(output);
_ => {
outputs.push(output);
}
}
}

Expand Down
36 changes: 16 additions & 20 deletions crankshaft-engine/src/task/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ impl Builder {
inputs.extend(new);
Some(inputs)
}
None => {
if let Some(input) = new.next() {
None => match new.next() {
Some(input) => {
let mut inputs = NonEmpty::new(input);
inputs.extend(new);
Some(inputs)
} else {
None
}
}
_ => None,
},
};

self
Expand All @@ -122,15 +121,14 @@ impl Builder {
outputs.extend(new);
Some(outputs)
}
None => {
if let Some(output) = new.next() {
None => match new.next() {
Some(output) => {
let mut outputs = NonEmpty::new(output);
outputs.extend(new);
Some(outputs)
} else {
None
}
}
_ => None,
},
};

self
Expand Down Expand Up @@ -159,15 +157,14 @@ impl Builder {
executors.extend(new);
Some(executors)
}
None => {
if let Some(executor) = new.next() {
None => match new.next() {
Some(executor) => {
let mut executors = NonEmpty::new(executor);
executors.extend(new);
Some(executors)
} else {
None
}
}
_ => None,
},
};

self
Expand All @@ -185,15 +182,14 @@ impl Builder {
volumes.extend(new);
Some(volumes)
}
None => {
if let Some(volume) = new.next() {
None => match new.next() {
Some(volume) => {
let mut volumes: NonEmpty<_> = NonEmpty::new(volume);
volumes.extend(new);
Some(volumes)
} else {
None
}
}
_ => None,
},
};

self
Expand Down
9 changes: 4 additions & 5 deletions crankshaft-engine/src/task/execution/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@ impl Builder {
args.extend(values);
Some(args)
}
None => {
if let Some(arg) = values.next() {
None => match values.next() {
Some(arg) => {
let mut args = NonEmpty::new(arg);
args.extend(values);
Some(args)
} else {
None
}
}
_ => None,
},
};

self
Expand Down
9 changes: 4 additions & 5 deletions crankshaft-engine/src/task/resources/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,14 @@ impl Builder {
zones.extend(values);
Some(zones)
}
None => {
if let Some(zone) = values.next() {
None => match values.next() {
Some(zone) => {
let mut zones = NonEmpty::new(zone);
zones.extend(values);
Some(zones)
} else {
None
}
}
_ => None,
},
};

self
Expand Down

0 comments on commit 59adfe3

Please sign in to comment.