|
|
|
@ -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<T, Box<dyn Error>>`
|
|
|
|
|
/// * `$($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)*) => {
|
|
|
|
|