From d163f9f114c8180bec6285ad9962fabbf3af5b18 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 4 Sep 2020 13:33:07 +0300 Subject: Small refactoring --- crates/vfs/src/file_set.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/vfs') diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index 956cffb29..3085fd818 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs @@ -30,33 +30,33 @@ impl FileSet { self.paths[&file].file_name_and_extension() } - pub fn list_files( + pub fn list_files_with_extensions( &self, anchor: FileId, anchor_relative_path: Option<&str>, - ) -> Option> { + ) -> Vec<(&str, Option<&str>)> { let anchor_directory = { let path = self.paths[&anchor].clone(); match anchor_relative_path { Some(anchor_relative_path) => path.join(anchor_relative_path), None => path.parent(), } - }?; + }; - Some( + if let Some(anchor_directory) = anchor_directory { self.paths .iter() - .filter_map(|(&file_id, path)| { - if path.parent()? == anchor_directory - && matches!(path.file_name_and_extension(), Some((_, Some("rs")))) - { - Some(file_id) + .filter_map(|(_, path)| { + if path.parent()? == anchor_directory { + path.file_name_and_extension() } else { None } }) - .collect(), - ) + .collect() + } else { + Vec::new() + } } pub fn insert(&mut self, file_id: FileId, path: VfsPath) { self.files.insert(path.clone(), file_id); -- cgit v1.2.3