Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: use is_some_and/is_ok_and #451

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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