Skip to content

Commit

Permalink
Apply patch from NK, allowing to compile with Rust 1.68
Browse files Browse the repository at this point in the history
  • Loading branch information
trou committed Jul 3, 2023
1 parent 0e63daa commit 2536493
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ pub fn load_corpus(path: &str) -> Result<Vec<CorpusStats>, 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
Expand Down
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -222,7 +225,10 @@ fn main() -> Result<()> {

let corpus_dir = args.get_one::<String>("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::<String>("corpus").unwrap().to_owned() + "/*.corpus";
println!("Loading corpus from {}", corpus_files);
Expand Down

0 comments on commit 2536493

Please sign in to comment.