Use Iterator methods

This commit is contained in:
Shotaro Yamada 2018-04-01 18:43:52 +09:00
parent ed46a777c8
commit 6b3811a358
2 changed files with 3 additions and 25 deletions

View file

@ -271,13 +271,7 @@ impl IgnoreList {
}
fn skip_file_inner(&self, file: &Path) -> bool {
for path in &self.0 {
if file.starts_with(path) {
return true;
}
}
false
self.0.iter().any(|path| file.starts_with(path))
}
pub fn skip_file(&self, file: &FileName) -> bool {

View file

@ -32,16 +32,7 @@ fn prune_files(files: Vec<&str>) -> Vec<&str> {
let mut pruned_prefixes = vec![];
for p1 in prefixes {
let mut include = true;
if !p1.starts_with("src/bin/") {
for p2 in &pruned_prefixes {
if p1.starts_with(p2) {
include = false;
break;
}
}
}
if include {
if p1.starts_with("src/bin/") || pruned_prefixes.iter().all(|p2| !p1.starts_with(p2)) {
pruned_prefixes.push(p1);
}
}
@ -50,17 +41,10 @@ fn prune_files(files: Vec<&str>) -> Vec<&str> {
files
.into_iter()
.filter(|f| {
let mut include = true;
if f.ends_with("mod.rs") || f.ends_with("lib.rs") || f.starts_with("src/bin/") {
return true;
}
for pp in &pruned_prefixes {
if f.starts_with(pp) {
include = false;
break;
}
}
include
pruned_prefixes.iter().all(|pp| !f.starts_with(pp))
})
.collect()
}