]> git.lizzy.rs Git - rust.git/blobdiff - crates/vfs/src/loader.rs
Fix: prefer the usage of `for` loops over `fold`
[rust.git] / crates / vfs / src / loader.rs
index 5959ce2ce79a66c742eceae9bbc97b02c1121e36..c341b974a04dd4e48dcce6231a5677ba582c298e 100644 (file)
@@ -161,16 +161,15 @@ pub fn contains_dir(&self, path: &AbsPath) -> bool {
     ///   - This path is longer than any element in `self.exclude` that is a prefix
     ///     of `path`. In case of equality, exclusion wins.
     fn includes_path(&self, path: &AbsPath) -> bool {
-        let include = self.include.iter().fold(None::<&AbsPathBuf>, |include, incl| {
-            if !path.starts_with(incl) {
-                return include;
+        let mut include = None::<&AbsPathBuf>;
+        for incl in &self.include {
+            if path.starts_with(incl) {
+                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 {
             Some(it) => it,