Explorar el Código

Actually use the is_dotfile method

Ben S hace 11 años
padre
commit
709fb71e69
Se han modificado 1 ficheros con 5 adiciones y 13 borrados
  1. 5 13
      src/options.rs

+ 5 - 13
src/options.rs

@@ -76,10 +76,11 @@ impl Options {
     }
 
     /// Transform the files somehow before listing them.
-    pub fn transform_files<'a>(&self, unordered_files: Vec<File<'a>>) -> Vec<File<'a>> {
-        let mut files: Vec<File<'a>> = unordered_files.into_iter()
-            .filter(|f| self.should_display(f))
-            .collect();
+    pub fn transform_files<'a>(&self, mut files: Vec<File<'a>>) -> Vec<File<'a>> {
+
+        if !self.show_invisibles {
+            files = files.into_iter().filter(|f| !f.is_dotfile()).collect();
+        }
 
         match self.sort_field {
             SortField::Unsorted => {},
@@ -99,15 +100,6 @@ impl Options {
 
         files
     }
-
-    fn should_display(&self, f: &File) -> bool {
-        if self.show_invisibles {
-            true
-        }
-        else {
-            !f.name.as_slice().starts_with(".")
-        }
-    }
 }
 
 /// User-supplied field to sort by