I have an instance of type MyError
which implements std::error::Error
and overrides the default fn source
.
How, would I go about using that to get a reference to the concrete type that was used when making the instance of MyError
?
I have the following snippet:
let e: MyError = ...;
if let Some(s) = e.source() {
if let Some(s_err) = s.as_any().downcast_ref::<SourceErr>() {
...
}
}
But the compiler complains that no method as_any exists for &dyn std:error::Error
. I have tried looking for another solution to this but I have failed to.