File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments