core: Implement and export the try! macro

This is used quite extensively by core::fmt
This commit is contained in:
Alex Crichton 2014-05-10 13:48:26 -07:00
parent f2af4ca3e6
commit 27d8ea05a2

@ -59,3 +59,9 @@ macro_rules! assert(
macro_rules! debug_assert(
($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); })
)
/// Short circuiting evaluation on Err
#[macro_export]
macro_rules! try(
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
)