dtolnay / dtolnay/anyhow

anyhow::Error to Box<dyn Error> isn't compatible with other libraries

Open
#356 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
6.7k
Forks
224
PR merge metrics
No merged PRs in 30d

Description

Hello,

I have to use multiple internal crates which mix and match `anyhow` and `eyre`. When trying to convert between the two, I have convert `anyhow::Error` to `Box`, which then complains that conversion requires `dyn Error` to be `Sized` (in order for `Box` to implement `Error`). This results in this ugly solution when using `Result`:

```rust
result
// Both `anyhow::Error` and `eyre::Report` support conversion into `Box`
.map_err(Into::>::into)
// However, I have to stuff it into `Arc` which implements `Error` for `?Sized`
.map_err(Into::>::into)?
```

Is there a better solution to this? If not, would it be possible to add conversion implementation from `anyhow::Error` into `Arc` or something equivalent? Unfortunately, I am unable to implement it, as it would require use of unsafe (with which I do not have enough experience) and because I am unfamiliar with techniques used in `anyhow` thinning.

Thank you very much in advance.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.