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)*) => {