From 4d526f9df991f0f98ce3602743f3517f2d2ffc81 Mon Sep 17 00:00:00 2001 From: rasul Date: Sun, 5 Apr 2020 13:01:06 -0500 Subject: [PATCH] document the try_send_error!() macro --- src/macros.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/macros.rs b/src/macros.rs index cd3ccf0..7a91e86 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -66,7 +66,28 @@ macro_rules! try_print { }; } -/// Unwrap a `Result`, if it's an error then let client know and return. +/// Unwrap a Result. If it's Err then print the error and return a generic +/// error message for the client. +/// +/// # Arguments +/// +/// * `$i:ident` : mio::Token to designate the client +/// * `$e:expr` : Expression to evaluate, must return `Result>` +/// +/// # Example +/// +/// ``` +/// use std::fs::File; +/// use mio::Token; +/// use rude::result::RudeResult; +/// use rude::try_send_error; +/// +/// fn main() -> RudeResult<()> { +/// let token = Token(12); +/// let file = try_send_error!(token, File::open(file!())); +/// Ok(()) +/// } +/// ``` #[macro_export] macro_rules! try_send_error { ($i:ident, $e:expr) => {