Skip to content

Commit 359bf1d

Browse files
committed
Delte unused vfs method, document set_file_id_contents
1 parent 09a3888 commit 359bf1d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

crates/vfs/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ impl Vfs {
133133
self.get(file_id).as_deref().unwrap()
134134
}
135135

136-
/// File content, but returns None if the file was deleted.
137-
pub fn file_contents_opt(&self, file_id: FileId) -> Option<&[u8]> {
138-
self.get(file_id).as_deref()
139-
}
140-
141136
/// Returns the overall memory usage for the stored files.
142137
pub fn memory_usage(&self) -> usize {
143138
self.data.iter().flatten().map(|d| d.capacity()).sum()
@@ -167,6 +162,12 @@ impl Vfs {
167162
self.set_file_id_contents(file_id, contents)
168163
}
169164

165+
/// Update the given `file_id` with the given `contents`. `None` means the file was deleted.
166+
///
167+
/// Returns `true` if the file was modified, and saves the [change](ChangedFile).
168+
///
169+
/// If the path does not currently exists in the `Vfs`, allocates a new
170+
/// [`FileId`] for it.
170171
pub fn set_file_id_contents(&mut self, file_id: FileId, mut contents: Option<Vec<u8>>) -> bool {
171172
let change_kind = match (self.get(file_id), &contents) {
172173
(None, None) => return false,

0 commit comments

Comments
 (0)