Skip to content

Commit

Permalink
clippy: use is_some_and/is_ok_and (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog authored Nov 21, 2024
2 parents e761345 + 677bd1f commit c8d09ab
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/fnvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn type_replacements(type_: &Type, error_exprs: &[Expr]) -> impl Iterator<Item =
}

fn path_ends_with(path: &Path, ident: &str) -> 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> {
Expand Down
4 changes: 2 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ impl Colors {
/// detected terminal characteristics.
pub fn forced_value(&self) -> Option<bool> {
// 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<ProcessStatus>> {
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))
Expand Down
2 changes: 1 addition & 1 deletion tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c8d09ab

Please sign in to comment.