From f0dbba8cbef36f33221e164902b0f6450c4779bf Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 15 Feb 2019 10:59:12 +0100 Subject: [PATCH] tools.rs: new try_block macro --- src/tools.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools.rs b/src/tools.rs index bb6cc5e2..fa970798 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -27,6 +27,11 @@ pub mod ticket; pub mod borrow; pub mod fs; +#[macro_export] +macro_rules! try_block { + { $($token:tt)* } => {{ (|| -> Result<_,_> { $($token)* })() }} +} + /// The `BufferedReader` trait provides a single function /// `buffered_read`. It returns a reference to an internal buffer. The /// purpose of this traid is to avoid unnecessary data copies.