Skip to content

Commit 0986632

Browse files
committed
Fix: revert strange usage of ? operator
1 parent 27605b4 commit 0986632

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

crates/vfs/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ impl Vfs {
111111

112112
/// Id of the given path if it exists in the `Vfs` and is not deleted.
113113
pub fn file_id(&self, path: &VfsPath) -> Option<FileId> {
114-
let it = self.interner.get(path)?;
115-
let _ = self.get(it).as_ref()?;
116-
Some(it)
114+
self.interner.get(path).filter(|&it| self.get(it).is_some())
117115
}
118116

119117
/// File path corresponding to the given `file_id`.
@@ -139,12 +137,13 @@ impl Vfs {
139137
///
140138
/// This will skip deleted files.
141139
pub fn iter(&self) -> impl Iterator<Item = (FileId, &VfsPath)> + '_ {
142-
(0..self.data.len()).filter_map(move |it| {
143-
let file_id = FileId(it as u32);
144-
let _ = self.get(file_id).as_ref()?;
145-
let path = self.interner.lookup(file_id);
146-
Some((file_id, path))
147-
})
140+
(0..self.data.len())
141+
.map(|it| FileId(it as u32))
142+
.filter(move |&file_id| self.get(file_id).is_some())
143+
.map(move |file_id| {
144+
let path = self.interner.lookup(file_id);
145+
(file_id, path)
146+
})
148147
}
149148

150149
/// Update the `path` with the given `contents`. `None` means the file was deleted.

0 commit comments

Comments
 (0)