From 632d5dfcbe568692729f677e834b07dc542c1542 Mon Sep 17 00:00:00 2001 From: rasul Date: Sun, 5 Apr 2020 12:52:30 -0500 Subject: [PATCH] document try_print!() macro --- src/macros.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 5cf3c4c..875efac 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -33,8 +33,26 @@ macro_rules! try_log { }; } -/// Unwrap a Result, if it's Err then print the error and the provided format -/// string and return. +/// Unwrap a Result. If it's Err then print the error and provided format string +/// and return. +/// +/// # Arguments +/// +/// * `$e:expr` : Expression to evaluate, must return `Result>` +/// * `$($arg:tt)*` : Format string and parameters (like `println!()`) +/// +/// # Example +/// +/// ``` +/// use std::fs::File; +/// use rude::result::RudeResult; +/// use rude::try_print; +/// +/// fn main() -> RudeResult<()> { +/// let readme = try_print!(File::open(file!()), "Unable to open {}", file!()); +/// Ok(()) +/// } +/// ``` #[macro_export] macro_rules! try_print { ($e:expr, $($arg:tt)*) => {