try_er! is obsolete, since it's the same as try_e!

This commit is contained in:
Julian Ospald 2017-07-15 01:55:45 +02:00
parent 7542d8beaf
commit 28df945631
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

View File

@ -79,33 +79,18 @@ macro_rules! try_r {
} }
#[macro_export] #[macro_export]
/// Try to unwrap a `Result<T, E>`. If there is a value `T`, yield it, /// Try to unwrap a `Result<T, E>`. If there is a value `T`, yield it,
/// otherwise print an error and exit the program. /// otherwise print an error and exit the program.
macro_rules! try_e { macro_rules! try_e {
($expr:expr) => { ($expr:expr) => (match $expr {
try_er!($expr, ())
};
($expr:expr, $fmt:expr, $($arg:tt)+) => {
try_er!($expr, (), $fmt, $(arg)+)
};
($expr:expr, $fmt:expr) => {
try_er!($expr, (), $fmt)
}
}
#[macro_export]
macro_rules! try_er {
($expr:expr, $ret:expr) => (match $expr {
::std::result::Result::Ok(val) => val, ::std::result::Result::Ok(val) => val,
::std::result::Result::Err(err) => { ::std::result::Result::Err(err) => {
error!("{:?}", err); error!("{:?}", err);
::std::process::exit(1); ::std::process::exit(1);
}, },
}); });
($expr:expr, $ret:expr, $fmt:expr) => (match $expr { ($expr:expr, $fmt:expr) => (match $expr {
::std::result::Result::Ok(val) => val, ::std::result::Result::Ok(val) => val,
::std::result::Result::Err(err) => { ::std::result::Result::Err(err) => {
error!("Original error: {:?}", err); error!("Original error: {:?}", err);
@ -113,7 +98,7 @@ macro_rules! try_er {
std::process::exit(1); std::process::exit(1);
}, },
}); });
($expr:expr, $ret:expr, $fmt:expr, $($arg:tt)+) => (match $expr { ($expr:expr, $fmt:expr, $($arg:tt)+) => (match $expr {
::std::result::Result::Ok(val) => val, ::std::result::Result::Ok(val) => val,
::std::result::Result::Err(err) => { ::std::result::Result::Err(err) => {
error!("Original error: {:?}", err); error!("Original error: {:?}", err);