We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
filter_map
1 parent e912d65 commit 0765c97Copy full SHA for 0765c97
crates/vfs/src/lib.rs
@@ -139,13 +139,12 @@ impl Vfs {
139
///
140
/// This will skip deleted files.
141
pub fn iter(&self) -> impl Iterator<Item = (FileId, &VfsPath)> + '_ {
142
- (0..self.data.len())
143
- .map(|it| FileId(it as u32))
144
- .filter(move |&file_id| self.get(file_id).is_some())
145
- .map(move |file_id| {
146
- let path = self.interner.lookup(file_id);
147
- (file_id, path)
148
- })
+ (0..self.data.len()).filter_map(move |it| {
+ let file_id = FileId(it as u32);
+ let _ = self.get(file_id).as_ref()?;
+ let path = self.interner.lookup(file_id);
+ Some((file_id, path))
+ })
149
}
150
151
/// Update the `path` with the given `contents`. `None` means the file was deleted.
0 commit comments