failure
failure copied to clipboard
bail macro in try block
What do you think about changing the bail
macro for use it or ensure
in the try-blocks?
current:
#[macro_export]
macro_rules! bail {
($e:expr) => {
return Err($crate::err_msg($e));
};
($fmt:expr, $($arg:tt)+) => {
return Err($crate::err_msg(format!($fmt, $($arg)+)));
};
}
changed:
#[macro_export]
macro_rules! bail {
($e:expr) => {
Err($crate::err_msg($e))?;
};
($fmt:expr, $($arg:tt)+) => {
Err($crate::err_msg(format!($fmt, $($arg)+)))?;
};
}
@kgv I didn't realize try {}
blocks were available already! Do you have any links to (nightly) docs / feature tracking issues? It would probably help provide some context for anyone that hasn't caught up on the latest around try {}
(e.g. people like me, haha). Thanks!
@yoshuawuyts try-blocks
I think I'm in favour of this change. Would accept a PR if it comes with tests.
Would also fix https://github.com/rust-lang-nursery/failure/issues/110 which just tripped me up as unobvious (bail!
is strictly less versatile than ?
)