mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Refactor: use iterator methods over for
loops
This commit is contained in:
parent
6d0336b2e4
commit
7ee6cca3d7
1 changed files with 12 additions and 14 deletions
|
@ -155,25 +155,23 @@ impl Directories {
|
||||||
/// - This path is longer than any element in `self.exclude` that is a prefix
|
/// - This path is longer than any element in `self.exclude` that is a prefix
|
||||||
/// of `path`. In case of equality, exclusion wins.
|
/// of `path`. In case of equality, exclusion wins.
|
||||||
fn includes_path(&self, path: &AbsPath) -> bool {
|
fn includes_path(&self, path: &AbsPath) -> bool {
|
||||||
let mut include: Option<&AbsPathBuf> = None;
|
let include = self.include.iter().fold(None::<&AbsPathBuf>, |include, incl| {
|
||||||
for incl in &self.include {
|
if !path.starts_with(incl) {
|
||||||
if path.starts_with(incl) {
|
return include;
|
||||||
include = Some(match include {
|
|
||||||
Some(prev) if prev.starts_with(incl) => prev,
|
|
||||||
_ => incl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Some(match include {
|
||||||
|
Some(prev) if prev.starts_with(incl) => prev,
|
||||||
|
_ => incl,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
let include = match include {
|
let include = match include {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => return false,
|
None => return false,
|
||||||
};
|
};
|
||||||
for excl in &self.exclude {
|
|
||||||
if path.starts_with(excl) && excl.starts_with(include) {
|
!self.exclude.iter().any(|excl| path.starts_with(excl) && excl.starts_with(include))
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue