Skip to content

Commit 27605b4

Browse files
committed
Fix: prefer the usage of for loops over fold
1 parent 0e480a6 commit 27605b4

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

crates/vfs/src/loader.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,15 @@ impl Directories {
161161
/// - This path is longer than any element in `self.exclude` that is a prefix
162162
/// of `path`. In case of equality, exclusion wins.
163163
fn includes_path(&self, path: &AbsPath) -> bool {
164-
let include = self.include.iter().fold(None::<&AbsPathBuf>, |include, incl| {
165-
if !path.starts_with(incl) {
166-
return include;
164+
let mut include = None::<&AbsPathBuf>;
165+
for incl in &self.include {
166+
if path.starts_with(incl) {
167+
include = Some(match include {
168+
Some(prev) if prev.starts_with(incl) => prev,
169+
_ => incl,
170+
});
167171
}
168-
169-
Some(match include {
170-
Some(prev) if prev.starts_with(incl) => prev,
171-
_ => incl,
172-
})
173-
});
172+
}
174173

175174
let include = match include {
176175
Some(it) => it,

0 commit comments

Comments
 (0)