Macro failure_ext::err_downcast_ref
source · macro_rules! err_downcast_ref { ( $err:expr ) => { ... }; ( $err:expr, $($v:ident : $ty:ty => $action:expr),* , ) => { ... }; ( $err:expr, $v:ident : $ty:ty => $action:expr $(, $rv:ident : $rty:ty => $raction:expr)* ) => { ... }; }
Expand description
Downcast matching.
Usage:
let res = err_downcast_ref! {
err,
ty: Type => { /* use ty as &Type */ },
yours: YourType => { /* use yours as &YourType */ },
};
Where err
is a &anyhow::Error
.
When one of the type arms match, then it returns Some(value from expr), otherwise None.
It’s like downcast_ref but for multiple types.