File tree 4 files changed +26
-15
lines changed
4 files changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ impl From<VfsErrorKind> for VfsError {
26
26
let kind = match kind {
27
27
VfsErrorKind :: IoError ( io) => match io. kind ( ) {
28
28
io:: ErrorKind :: NotFound => VfsErrorKind :: FileNotFound ,
29
- io:: ErrorKind :: Unsupported => VfsErrorKind :: NotSupported ,
29
+ // TODO: If MSRV changes to 1.53, enable this. Alternatively,
30
+ // if it's possible to #[cfg] just this line, try that
31
+ // io::ErrorKind::Unsupported => VfsErrorKind::NotSupported,
30
32
_ => VfsErrorKind :: IoError ( io) ,
31
33
} ,
32
34
// Remaining kinda are passed through as-is
Original file line number Diff line number Diff line change @@ -35,15 +35,15 @@ pub trait FileSystem: Debug + Sync + Send + 'static {
35
35
/// Removes the directory at this path
36
36
fn remove_dir ( & self , path : & str ) -> VfsResult < ( ) > ;
37
37
/// Copies the src path to the destination path within the same filesystem (optional)
38
- fn copy_file ( & self , _src : & str , dest : & str ) -> VfsResult < ( ) > {
38
+ fn copy_file ( & self , _src : & str , _dest : & str ) -> VfsResult < ( ) > {
39
39
Err ( VfsErrorKind :: NotSupported . into ( ) )
40
40
}
41
41
/// Moves the src path to the destination path within the same filesystem (optional)
42
- fn move_file ( & self , _src : & str , dest : & str ) -> VfsResult < ( ) > {
42
+ fn move_file ( & self , _src : & str , _dest : & str ) -> VfsResult < ( ) > {
43
43
Err ( VfsErrorKind :: NotSupported . into ( ) )
44
44
}
45
45
/// Moves the src directory to the destination path within the same filesystem (optional)
46
- fn move_dir ( & self , _src : & str , dest : & str ) -> VfsResult < ( ) > {
46
+ fn move_dir ( & self , _src : & str , _dest : & str ) -> VfsResult < ( ) > {
47
47
Err ( VfsErrorKind :: NotSupported . into ( ) )
48
48
}
49
49
}
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ impl FileSystem for MemoryFS {
162
162
fn open_file ( & self , path : & str ) -> VfsResult < Box < dyn SeekAndRead > > {
163
163
let handle = self . handle . read ( ) . unwrap ( ) ;
164
164
let file = handle. files . get ( path) . ok_or ( VfsErrorKind :: FileNotFound ) ?;
165
- ensure_file ( path , file) ?;
165
+ ensure_file ( file) ?;
166
166
Ok ( Box :: new ( ReadableFile {
167
167
content : file. content . clone ( ) ,
168
168
position : 0 ,
@@ -356,7 +356,7 @@ mod tests {
356
356
}
357
357
}
358
358
359
- fn ensure_file ( path : & str , file : & MemoryFile ) -> VfsResult < ( ) > {
359
+ fn ensure_file ( file : & MemoryFile ) -> VfsResult < ( ) > {
360
360
if file. file_type != VfsFileType :: File {
361
361
return Err ( VfsErrorKind :: Other ( "Not a file" . into ( ) ) . into ( ) ) ;
362
362
}
Original file line number Diff line number Diff line change @@ -673,9 +673,12 @@ impl VfsPath {
673
673
if Arc :: ptr_eq ( & self . fs , & destination. fs ) {
674
674
let result = self . fs . fs . copy_file ( & self . path , & destination. path ) ;
675
675
match result {
676
- Err ( err) if matches ! ( err. kind( ) , VfsErrorKind :: NotSupported ) => {
677
- // continue
678
- }
676
+ Err ( err) => match err. kind ( ) {
677
+ VfsErrorKind :: NotSupported => {
678
+ // continue
679
+ }
680
+ _ => return Err ( err) ,
681
+ } ,
679
682
other => return other,
680
683
}
681
684
}
@@ -729,9 +732,12 @@ impl VfsPath {
729
732
if Arc :: ptr_eq ( & self . fs , & destination. fs ) {
730
733
let result = self . fs . fs . move_file ( & self . path , & destination. path ) ;
731
734
match result {
732
- Err ( err) if matches ! ( err. kind( ) , VfsErrorKind :: NotSupported ) => {
733
- // continue
734
- }
735
+ Err ( err) => match err. kind ( ) {
736
+ VfsErrorKind :: NotSupported => {
737
+ // continue
738
+ }
739
+ _ => return Err ( err) ,
740
+ } ,
735
741
other => return other,
736
742
}
737
743
}
@@ -840,9 +846,12 @@ impl VfsPath {
840
846
if Arc :: ptr_eq ( & self . fs , & destination. fs ) {
841
847
let result = self . fs . fs . move_dir ( & self . path , & destination. path ) ;
842
848
match result {
843
- Err ( err) if matches ! ( err. kind( ) , VfsErrorKind :: NotSupported ) => {
844
- // continue
845
- }
849
+ Err ( err) => match err. kind ( ) {
850
+ VfsErrorKind :: NotSupported => {
851
+ // continue
852
+ }
853
+ _ => return Err ( err) ,
854
+ } ,
846
855
other => return other,
847
856
}
848
857
}
You can’t perform that action at this time.
0 commit comments