@@ -140,10 +140,12 @@ impl SessionFsProvider for InMemorySqliteProvider {
140140 let prefix = format ! ( "{}/" , path. trim_end_matches( '/' ) ) ;
141141 let mut names = std:: collections:: BTreeSet :: new ( ) ;
142142 for p in files. keys ( ) . chain ( dirs. iter ( ) ) {
143- if let Some ( rest) = p. strip_prefix ( & prefix) {
144- if let Some ( name) = rest. split ( '/' ) . next ( ) . filter ( |n| !n. is_empty ( ) ) {
145- names. insert ( name. to_string ( ) ) ;
146- }
143+ if let Some ( name) = p
144+ . strip_prefix ( & prefix)
145+ . and_then ( |rest| rest. split ( '/' ) . next ( ) )
146+ . filter ( |n| !n. is_empty ( ) )
147+ {
148+ names. insert ( name. to_string ( ) ) ;
147149 }
148150 }
149151 Ok ( names. into_iter ( ) . collect ( ) )
@@ -155,19 +157,23 @@ impl SessionFsProvider for InMemorySqliteProvider {
155157 let prefix = format ! ( "{}/" , path. trim_end_matches( '/' ) ) ;
156158 let mut entries: HashMap < String , DirEntryKind > = HashMap :: new ( ) ;
157159 for d in dirs. iter ( ) {
158- if let Some ( rest) = d. strip_prefix ( & prefix) {
159- if let Some ( name) = rest. split ( '/' ) . next ( ) . filter ( |n| !n. is_empty ( ) ) {
160- entries. insert ( name. to_string ( ) , DirEntryKind :: Directory ) ;
161- }
160+ if let Some ( name) = d
161+ . strip_prefix ( & prefix)
162+ . and_then ( |rest| rest. split ( '/' ) . next ( ) )
163+ . filter ( |n| !n. is_empty ( ) )
164+ {
165+ entries. insert ( name. to_string ( ) , DirEntryKind :: Directory ) ;
162166 }
163167 }
164168 for f in files. keys ( ) {
165- if let Some ( rest) = f. strip_prefix ( & prefix) {
166- if let Some ( name) = rest. split ( '/' ) . next ( ) . filter ( |n| !n. is_empty ( ) ) {
167- entries
168- . entry ( name. to_string ( ) )
169- . or_insert ( DirEntryKind :: File ) ;
170- }
169+ if let Some ( name) = f
170+ . strip_prefix ( & prefix)
171+ . and_then ( |rest| rest. split ( '/' ) . next ( ) )
172+ . filter ( |n| !n. is_empty ( ) )
173+ {
174+ entries
175+ . entry ( name. to_string ( ) )
176+ . or_insert ( DirEntryKind :: File ) ;
171177 }
172178 }
173179 let mut result: Vec < DirEntry > = entries
0 commit comments