1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 15:40:03 +08:00

feat: add opt_value_result!

This commit is contained in:
2021-06-13 20:31:43 +08:00
parent c69cb1c35b
commit 568a2173d5
3 changed files with 18 additions and 1 deletions

View File

@@ -66,6 +66,17 @@ pub fn new_box_ioerror(m: &str) -> Box<dyn Error> {
Box::new(IoError::new(ErrorKind::Other, m))
}
#[macro_export] macro_rules! opt_value_result {
($ex: expr, $($arg:tt)+) => (
match $ex {
Some(o) => o,
None => return Err(rust_util::SimpleError::new(
format!("{}, file: {}, line: {}", format!($($arg)+), file!(), line!())
).into()),
}
)
}
#[macro_export] macro_rules! opt_result {
($ex: expr, $($arg:tt)+) => (
match $ex {