Skip to content

Commit

Permalink
style: Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed May 18, 2023
1 parent 58b03d2 commit 6114a09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion examples/example_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ fn run() -> Result<(), Box<dyn Error>> {
let code = env::var("exit")
.ok()
.map(|v| v.parse::<i32>())
.map_or(Ok(None), |r| r.map(Some))?
.map(|r| r.map(Some))
.unwrap_or(Ok(None))?
.unwrap_or(0);
process::exit(code);
}
Expand Down
7 changes: 4 additions & 3 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ impl Assert {
impl fmt::Display for Assert {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let palette = crate::Palette::color();
for &(ref name, ref context) in &self.context {
for (name, context) in &self.context {
writeln!(f, "{:#}=`{:#}`", palette.key(name), palette.value(context))?;
}
output_fmt(&self.output, f)
Expand Down Expand Up @@ -1069,8 +1069,9 @@ impl fmt::Display for AssertError {
AssertReason::UnexpectedFailure { actual_code } => writeln!(
f,
"Unexpected failure.\ncode-{}\nstderr=```{}```",
actual_code.map_or("<interrupted>".to_owned(), |actual_code| actual_code
.to_string()),
actual_code
.map(|actual_code| actual_code.to_string())
.unwrap_or_else(|| "<interrupted>".to_owned()),
DebugBytes::new(&self.assert.output.stderr),
),
AssertReason::UnexpectedSuccess => {
Expand Down
3 changes: 2 additions & 1 deletion src/bin/bin_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ fn run() -> Result<(), Box<dyn Error>> {
let code = env::var("exit")
.ok()
.map(|v| v.parse::<i32>())
.map_or(Ok(None), |r| r.map(Some))?
.map(|r| r.map(Some))
.unwrap_or(Ok(None))?
.unwrap_or(0);
process::exit(code);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub fn cargo_bin<S: AsRef<str>>(name: S) -> path::PathBuf {

fn cargo_bin_str(name: &str) -> path::PathBuf {
let env_var = format!("CARGO_BIN_EXE_{}", name);
std::env::var_os(&env_var)
std::env::var_os(env_var)
.map(|p| p.into())
.unwrap_or_else(|| target_dir().join(format!("{}{}", name, env::consts::EXE_SUFFIX)))
}

0 comments on commit 6114a09

Please sign in to comment.