Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

as_ref() type must be known at this point #348

Open
pronebird opened this issue Feb 3, 2024 · 0 comments
Open

as_ref() type must be known at this point #348

pronebird opened this issue Feb 3, 2024 · 0 comments

Comments

@pronebird
Copy link

Hi,

I have noticed that calling as_ref() on error returned from anyhow::Result<T> 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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant