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

result::Error should call Printable::disp if the err field implements Printable #39

Open
vaivaswatha opened this issue Aug 21, 2024 · 0 comments

Comments

@vaivaswatha
Copy link
Owner

Following up on #34 and #33, it would be nice if, when displaying the err field, if that object can be cast to Any, and that Any object into dyn Printable (via the trait_cast utility), then use that to print the field instead of just Display provided by thiserror.

Today, we try to downcast the err field to result::Error, and in that case, we can call Printable, but not for any other Rust type that implements Printable.

Note: result::Error::err has a as_any() method, but that's the Any object from the outer Box. What we want is (*self.err).as_any() to be used in ``impl Printable for Errorwhich doesn't work today becuasestd::error::Error` provides `downcast` but not `as_any`.

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