mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Simplify
This commit is contained in:
parent
bc4d047267
commit
3e688d2a93
1 changed files with 5 additions and 9 deletions
|
@ -83,11 +83,11 @@ impl Directories {
|
||||||
self.includes_path(path)
|
self.includes_path(path)
|
||||||
}
|
}
|
||||||
fn includes_path(&self, path: &AbsPath) -> bool {
|
fn includes_path(&self, path: &AbsPath) -> bool {
|
||||||
let mut include = None;
|
let mut include: Option<&AbsPathBuf> = None;
|
||||||
for incl in &self.include {
|
for incl in &self.include {
|
||||||
if is_prefix(incl, path) {
|
if path.starts_with(incl) {
|
||||||
include = Some(match include {
|
include = Some(match include {
|
||||||
Some(prev) if is_prefix(incl, prev) => prev,
|
Some(prev) if prev.starts_with(incl) => prev,
|
||||||
_ => incl,
|
_ => incl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -97,15 +97,11 @@ impl Directories {
|
||||||
None => return false,
|
None => return false,
|
||||||
};
|
};
|
||||||
for excl in &self.exclude {
|
for excl in &self.exclude {
|
||||||
if is_prefix(excl, path) && is_prefix(include, excl) {
|
if path.starts_with(excl) && excl.starts_with(include) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
true
|
||||||
|
|
||||||
fn is_prefix(short: &AbsPath, long: &AbsPath) -> bool {
|
|
||||||
long.strip_prefix(short).is_some()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue