diff --git a/src/corpus.rs b/src/corpus.rs index 1cb5545..0392786 100644 --- a/src/corpus.rs +++ b/src/corpus.rs @@ -50,11 +50,12 @@ pub fn load_corpus(path: &str) -> Result, Error> { Ok(CorpusStats::new(arch_name, &data, 0.01)) }) .collect(); - if res.as_ref().is_ok_and(|res_v| res_v.len() == 0) { - Err(Error::msg("Could not find any file in corpus directory")) - } else { - res + if let Result::Ok(res_v) = &res { + if res_v.is_empty() { + return Err(Error::msg("Could not find any file in corpus directory")); + } } + res } // Convenience struct for readability diff --git a/src/main.rs b/src/main.rs index 3f1b643..c1ed285 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,7 +157,10 @@ fn guess_with_windows( // Should we add the previous guess to the result ? yes if it's // either unknown (None) or different from the new one let do_push = match &win_res { - Some(wres) => !cur_guess.arch.as_ref().is_some_and(|a| a == wres), + Some(wres) => match cur_guess.arch.as_ref() { + Some(a) => a != wres, + None => true, + }, _ => true, }; if do_push { @@ -222,7 +225,10 @@ fn main() -> Result<()> { let corpus_dir = args.get_one::("corpus").unwrap().to_owned(); if !Path::new(&corpus_dir).is_dir() { - return Err(Error::msg(format!("{} is not a valid directory", corpus_dir))); + return Err(Error::msg(format!( + "{} is not a valid directory", + corpus_dir + ))); } let corpus_files: String = args.get_one::("corpus").unwrap().to_owned() + "/*.corpus"; println!("Loading corpus from {}", corpus_files);