manuel-woelker / rust-vfs

A virtual filesystem for Rust
Apache License 2.0
384 stars 44 forks source link

`VfsError` & `VfsResult` are incompatible with `anyhow` #39

Closed tats-u closed 2 years ago

tats-u commented 2 years ago

From 0.6.0, VfsResult cannot be unwrapped using the ? operator in functions that return anyhow::Result. Due to this, I cannot help using the version 0.5.2.

error[E0277]: the trait bound `VfsError: std::error::Error` is not satisfied
  --> tests\zip_output_test.rs:20:49
   |
20 |     let out_zip_vpath = vfs_root.join("out.zip")?;
   |                                                 ^ the trait `std::error::Error` is not implemented for `VfsError`
   |
   = help: the following other types implement trait `FromResidual<R>`:
             <Result<T, F> as FromResidual<Result<Infallible, E>>>
             <Result<T, F> as FromResidual<Yeet<E>>>
   = note: required because of the requirements on the impl of `From<VfsError>` for `anyhow::Error`
   = note: required because of the requirements on the impl of `FromResidual<Result<Infallible, VfsError>>` for `Result<(), anyhow::Error>`

I think that it is a regression and due to https://github.com/manuel-woelker/rust-vfs/issues/25.

manuel-woelker commented 2 years ago

Thanks for the report! std::error::Error compatibility was fixed a while back, I plain missed to create a new release. 0.8.0 is out now - please let me know if you have any further issues.

I also took the opportunity to add a test to ensure the anyhow result conversion works. https://github.com/manuel-woelker/rust-vfs/commit/d7c478e90da69ef55cecd89f2df95763da70fc78#diff-97e25e2a0e41c578875856e97b659be2719a65227c104b992e3144efa000c35e

tats-u commented 2 years ago

@manuel-woelker It works! Thank you for your fast response.