Skip to content

Commit 27d8ea0

Browse files
committed
core: Implement and export the try! macro
This is used quite extensively by core::fmt
1 parent f2af4ca commit 27d8ea0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libcore/macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ macro_rules! assert(
5959
macro_rules! debug_assert(
6060
($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); })
6161
)
62+
63+
/// Short circuiting evaluation on Err
64+
#[macro_export]
65+
macro_rules! try(
66+
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
67+
)

0 commit comments

Comments
 (0)