diff options
author | Arnaud <[email protected]> | 2021-01-12 16:41:45 +0000 |
---|---|---|
committer | Arnaud <[email protected]> | 2021-01-12 17:01:47 +0000 |
commit | 4b71c8332daf9ef461891d278f2cf3530baaa833 (patch) | |
tree | 1a0d16083438c999539c2c9e8a643e449e40fa53 /crates/vfs/src/lib.rs | |
parent | 311ec70d03c27b1b37457ef44510e735fcce0885 (diff) |
Document vfs private items
Diffstat (limited to 'crates/vfs/src/lib.rs')
-rw-r--r-- | crates/vfs/src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs index bae2c6118..e075d752b 100644 --- a/crates/vfs/src/lib.rs +++ b/crates/vfs/src/lib.rs | |||
@@ -176,6 +176,14 @@ impl Vfs { | |||
176 | pub fn take_changes(&mut self) -> Vec<ChangedFile> { | 176 | pub fn take_changes(&mut self) -> Vec<ChangedFile> { |
177 | mem::take(&mut self.changes) | 177 | mem::take(&mut self.changes) |
178 | } | 178 | } |
179 | |||
180 | /// Returns the id associated with `path` | ||
181 | /// | ||
182 | /// - If `path` does not exists in the `Vfs`, allocate a new id for it, associated with a | ||
183 | /// deleted file; | ||
184 | /// - Else, returns `path`'s id. | ||
185 | /// | ||
186 | /// Does not record a change. | ||
179 | fn alloc_file_id(&mut self, path: VfsPath) -> FileId { | 187 | fn alloc_file_id(&mut self, path: VfsPath) -> FileId { |
180 | let file_id = self.interner.intern(path); | 188 | let file_id = self.interner.intern(path); |
181 | let idx = file_id.0 as usize; | 189 | let idx = file_id.0 as usize; |
@@ -183,9 +191,21 @@ impl Vfs { | |||
183 | self.data.resize_with(len, || None); | 191 | self.data.resize_with(len, || None); |
184 | file_id | 192 | file_id |
185 | } | 193 | } |
194 | |||
195 | /// Returns the content associated with the given `file_id`. | ||
196 | /// | ||
197 | /// # Panics | ||
198 | /// | ||
199 | /// Panics if no file is associated to that id. | ||
186 | fn get(&self, file_id: FileId) -> &Option<Vec<u8>> { | 200 | fn get(&self, file_id: FileId) -> &Option<Vec<u8>> { |
187 | &self.data[file_id.0 as usize] | 201 | &self.data[file_id.0 as usize] |
188 | } | 202 | } |
203 | |||
204 | /// Mutably returns the content associated with the given `file_id`. | ||
205 | /// | ||
206 | /// # Panics | ||
207 | /// | ||
208 | /// Panics if no file is associated to that id. | ||
189 | fn get_mut(&mut self, file_id: FileId) -> &mut Option<Vec<u8>> { | 209 | fn get_mut(&mut self, file_id: FileId) -> &mut Option<Vec<u8>> { |
190 | &mut self.data[file_id.0 as usize] | 210 | &mut self.data[file_id.0 as usize] |
191 | } | 211 | } |