From be5bed744263997ff12eccd2c66846a08f280d38 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 20 Nov 2024 08:04:13 -0800 Subject: [PATCH 1/2] clippy: use is_some_and/is_ok_and --- src/fnvalue.rs | 2 +- src/options.rs | 4 ++-- src/process.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fnvalue.rs b/src/fnvalue.rs index 112afe92..c5e1baab 100644 --- a/src/fnvalue.rs +++ b/src/fnvalue.rs @@ -236,7 +236,7 @@ fn type_replacements(type_: &Type, error_exprs: &[Expr]) -> impl Iterator bool { - path.segments.last().map_or(false, |s| s.ident == ident) + path.segments.last().is_some_and(|s| s.ident == ident) } fn match_impl_iterator(TypeImplTrait { bounds, .. }: &TypeImplTrait) -> Option<&Type> { diff --git a/src/options.rs b/src/options.rs index 895a790f..0f596736 100644 --- a/src/options.rs +++ b/src/options.rs @@ -199,9 +199,9 @@ impl Colors { /// detected terminal characteristics. pub fn forced_value(&self) -> Option { // From https://bixense.com/clicolors/ - if env::var("NO_COLOR").map_or(false, |x| x != "0") { + if env::var("NO_COLOR").is_ok_and(|x| x != "0") { Some(false) - } else if env::var("CLICOLOR_FORCE").map_or(false, |x| x != "0") { + } else if env::var("CLICOLOR_FORCE").is_ok_and(|x| x != "0") { Some(true) } else { match self { diff --git a/src/process.rs b/src/process.rs index 1a9ab014..25f0600e 100644 --- a/src/process.rs +++ b/src/process.rs @@ -96,7 +96,7 @@ impl Process { /// Check if the child process has finished; if so, return its status. #[mutants::skip] // It's hard to avoid timeouts if this never works... pub fn poll(&mut self) -> Result> { - if self.timeout.map_or(false, |t| self.start.elapsed() > t) { + if self.timeout.is_some_and(|t| self.start.elapsed() > t) { debug!("timeout, terminating child process...",); self.terminate()?; Ok(Some(ProcessStatus::Timeout)) From 71aefb976df483f2282cef3982fdea6c810c9145 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 20 Nov 2024 08:26:43 -0800 Subject: [PATCH 2/2] clippy --- src/output.rs | 2 +- tests/util/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output.rs b/src/output.rs index 6e7b2c17..1505489a 100644 --- a/src/output.rs +++ b/src/output.rs @@ -141,7 +141,7 @@ impl OutputDir { let log_dir = output_dir.join("log"); create_dir(&log_dir).with_context(|| format!("create log directory {:?}", &log_dir))?; let diff_dir = output_dir.join("diff"); - create_dir(&diff_dir).context("create diff dir")?; + create_dir(diff_dir).context("create diff dir")?; // Create text list files. let mut list_file_options = OpenOptions::new(); diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 8124e6a0..07ec37ec 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -70,7 +70,7 @@ impl CommandInstaExt for assert_cmd::Command { // Copy the source for one testdata tree. pub fn copy_of_testdata(tree_name: &str) -> TempDir { assert!( - !tree_name.contains("/"), + !tree_name.contains('/'), "testdata tree name {tree_name:?} should be just the directory name" ); let tmp = TempDir::with_prefix(format!("cargo-mutants-testdata-{tree_name}-")).unwrap();