@@ -134,8 +134,7 @@ where
134134 // make code more testable
135135 . map ( |m| ( m, std:: fs:: canonicalize ( & m. dev_name ) ) )
136136 // Ignore non existing paths
137- . filter ( |m| m. 1 . is_ok ( ) )
138- . map ( |m| ( m. 0 , m. 1 . ok ( ) . unwrap ( ) ) )
137+ . filter_map ( |m| m. 1 . ok ( ) . map ( |m1| ( m. 0 , m1) ) )
139138 // Try to find canonicalized device name corresponding to entered path
140139 . find ( |m| m. 1 . eq ( & path) )
141140 . map ( |m| m. 0 ) ;
@@ -156,20 +155,20 @@ impl Filesystem {
156155 let stat_path = if mount_info. mount_dir . is_empty ( ) {
157156 #[ cfg( unix) ]
158157 {
159- mount_info. dev_name . clone ( ) . into ( )
158+ mount_info. dev_name . as_ref ( )
160159 }
161160 #[ cfg( windows) ]
162161 {
163162 // On windows, we expect the volume id
164- mount_info. dev_id . clone ( ) . into ( )
163+ mount_info. dev_id . as_ref ( )
165164 }
166165 } else {
167- mount_info. mount_dir . clone ( )
166+ mount_info. mount_dir . as_os_str ( )
168167 } ;
169168 #[ cfg( unix) ]
170- let usage = FsUsage :: new ( statfs ( & stat_path) . ok ( ) ?) ;
169+ let usage = FsUsage :: new ( statfs ( stat_path) . ok ( ) ?) ;
171170 #[ cfg( windows) ]
172- let usage = FsUsage :: new ( Path :: new ( & stat_path) ) . ok ( ) ?;
171+ let usage = FsUsage :: new ( Path :: new ( stat_path) ) . ok ( ) ?;
173172 Some ( Self {
174173 file,
175174 mount_info,
@@ -234,12 +233,10 @@ impl Filesystem {
234233 where
235234 P : AsRef < Path > ,
236235 {
237- let file = path. as_ref ( ) . as_os_str ( ) . to_owned ( ) ;
236+ let path = path. as_ref ( ) ;
237+ let file = path. as_os_str ( ) . to_owned ( ) ;
238238
239- let canonical_path = path
240- . as_ref ( )
241- . canonicalize ( )
242- . map_err ( |_| FsError :: InvalidPath ) ?;
239+ let canonical_path = path. canonicalize ( ) . map_err ( |_| FsError :: InvalidPath ) ?;
243240
244241 let stat_result = statfs ( canonical_path. as_os_str ( ) ) . map_err ( |_| FsError :: MountMissing ) ?;
245242 let mount_dir = find_mount_point ( & canonical_path) . map_err ( |_| FsError :: MountMissing ) ?;
0 commit comments