diff options
Diffstat (limited to 'vfs')
-rw-r--r-- | vfs/Cargo.toml | 2 | ||||
-rw-r--r-- | vfs/src/lib.rs | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/vfs/Cargo.toml b/vfs/Cargo.toml index 7a5dc6b..d1d654c 100644 --- a/vfs/Cargo.toml +++ b/vfs/Cargo.toml | |||
@@ -6,4 +6,4 @@ license = "MIT" | |||
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | indexmap = "1.6.2" | 8 | indexmap = "1.6.2" |
9 | 9 | rayon = "1.5.1" | |
diff --git a/vfs/src/lib.rs b/vfs/src/lib.rs index cd6cc03..2d7577d 100644 --- a/vfs/src/lib.rs +++ b/vfs/src/lib.rs | |||
@@ -5,6 +5,7 @@ use std::{ | |||
5 | }; | 5 | }; |
6 | 6 | ||
7 | use indexmap::IndexSet; | 7 | use indexmap::IndexSet; |
8 | use rayon::prelude::*; | ||
8 | 9 | ||
9 | #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] | 10 | #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] |
10 | pub struct FileId(pub u32); | 11 | pub struct FileId(pub u32); |
@@ -70,6 +71,13 @@ impl ReadOnlyVfs { | |||
70 | contents: self.get_str(*file_id), | 71 | contents: self.get_str(*file_id), |
71 | }) | 72 | }) |
72 | } | 73 | } |
74 | pub fn par_iter(&self) -> impl ParallelIterator<Item = VfsEntry> { | ||
75 | self.data.par_iter().map(move |(file_id, _)| VfsEntry { | ||
76 | file_id: *file_id, | ||
77 | file_path: self.file_path(*file_id), | ||
78 | contents: self.get_str(*file_id), | ||
79 | }) | ||
80 | } | ||
73 | } | 81 | } |
74 | 82 | ||
75 | pub struct VfsEntry<'ρ> { | 83 | pub struct VfsEntry<'ρ> { |