dtolnay / dtolnay/anyhow

as_ref() type must be known at this point

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

Description

Hi,

I have noticed that calling `as_ref()` on error returned from `anyhow::Result` always errors with `type must be known at this point`. It seems that simply casting to `dyn Error` works fine however requires that weird hoop before I can call my own traits implemented for anything that looks like `std::error::Error`:

```rs
let dyn_error = err.as_ref() as &dyn std::error::Error;
```

I looked at the source code and I am genuinely confused, what's going on there and how can one access `&dyn std::error::Error` from `anyhow::Error` without going through explicit cast?

Thanks.

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.