Skip to content

Commit

Permalink
Fix build and lint errors on MSRV and Stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Technohacker committed Jul 20, 2022
1 parent 26abc13 commit 3f56183
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ impl From<VfsErrorKind> for VfsError {
let kind = match kind {
VfsErrorKind::IoError(io) => match io.kind() {
io::ErrorKind::NotFound => VfsErrorKind::FileNotFound,
io::ErrorKind::Unsupported => VfsErrorKind::NotSupported,
// TODO: If MSRV changes to 1.53, enable this. Alternatively,
// if it's possible to #[cfg] just this line, try that
// io::ErrorKind::Unsupported => VfsErrorKind::NotSupported,
_ => VfsErrorKind::IoError(io),
},
// Remaining kinda are passed through as-is
Expand Down
6 changes: 3 additions & 3 deletions src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ pub trait FileSystem: Debug + Sync + Send + 'static {
/// Removes the directory at this path
fn remove_dir(&self, path: &str) -> VfsResult<()>;
/// Copies the src path to the destination path within the same filesystem (optional)
fn copy_file(&self, _src: &str, dest: &str) -> VfsResult<()> {
fn copy_file(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsErrorKind::NotSupported.into())
}
/// Moves the src path to the destination path within the same filesystem (optional)
fn move_file(&self, _src: &str, dest: &str) -> VfsResult<()> {
fn move_file(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsErrorKind::NotSupported.into())
}
/// Moves the src directory to the destination path within the same filesystem (optional)
fn move_dir(&self, _src: &str, dest: &str) -> VfsResult<()> {
fn move_dir(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsErrorKind::NotSupported.into())
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/impls/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl FileSystem for MemoryFS {
fn open_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndRead>> {
let handle = self.handle.read().unwrap();
let file = handle.files.get(path).ok_or(VfsErrorKind::FileNotFound)?;
ensure_file(path, file)?;
ensure_file(file)?;
Ok(Box::new(ReadableFile {
content: file.content.clone(),
position: 0,
Expand Down Expand Up @@ -356,7 +356,7 @@ mod tests {
}
}

fn ensure_file(path: &str, file: &MemoryFile) -> VfsResult<()> {
fn ensure_file(file: &MemoryFile) -> VfsResult<()> {
if file.file_type != VfsFileType::File {
return Err(VfsErrorKind::Other("Not a file".into()).into());
}
Expand Down
27 changes: 18 additions & 9 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,12 @@ impl VfsPath {
if Arc::ptr_eq(&self.fs, &destination.fs) {
let result = self.fs.fs.copy_file(&self.path, &destination.path);
match result {
Err(err) if matches!(err.kind(), VfsErrorKind::NotSupported) => {
// continue
}
Err(err) => match err.kind() {
VfsErrorKind::NotSupported => {
// continue
}
_ => return Err(err),
},
other => return other,
}
}
Expand Down Expand Up @@ -729,9 +732,12 @@ impl VfsPath {
if Arc::ptr_eq(&self.fs, &destination.fs) {
let result = self.fs.fs.move_file(&self.path, &destination.path);
match result {
Err(err) if matches!(err.kind(), VfsErrorKind::NotSupported) => {
// continue
}
Err(err) => match err.kind() {
VfsErrorKind::NotSupported => {
// continue
}
_ => return Err(err),
},
other => return other,
}
}
Expand Down Expand Up @@ -840,9 +846,12 @@ impl VfsPath {
if Arc::ptr_eq(&self.fs, &destination.fs) {
let result = self.fs.fs.move_dir(&self.path, &destination.path);
match result {
Err(err) if matches!(err.kind(), VfsErrorKind::NotSupported) => {
// continue
}
Err(err) => match err.kind() {
VfsErrorKind::NotSupported => {
// continue
}
_ => return Err(err),
},
other => return other,
}
}
Expand Down

0 comments on commit 3f56183

Please sign in to comment.