|
|
@ -66,7 +66,28 @@ macro_rules! try_print {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Unwrap a `Result<T, E>`, 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<T, Box<dyn Error>>`
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # 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_export]
|
|
|
|
macro_rules! try_send_error {
|
|
|
|
macro_rules! try_send_error {
|
|
|
|
($i:ident, $e:expr) => {
|
|
|
|
($i:ident, $e:expr) => {
|
|
|
|