Macro utils_results::errextract [−][src]
macro_rules! errextract {
($result : expr, $kind : ty => $match : expr) => { ... };
}
Expand description
non panic unwraping and specific error can return matching block
other errors will go out -> Result<T>
ⓘ
fn exe(path: &str) -> Result<usize> {
let file = errcast!(File::open("test"), err::FileOpenError);
// .....
// ...
Ok(num)
}
fn main() -> Result<()> {
/// non panic unwraping
/// and specific error can return
/// matching block
let num = errextract!(exe(path),
err::FileOpenError => 0);
/// other errors will go out -> Result<T>
Ok(())
}