#![macro_use] /// check result macro, where the Ok() is the type which should be returned #[macro_export] macro_rules! check_result { ($v:expr) => { match $v { Ok(t) => t, Err(msg) => return Err(msg), } }; } /// check result macro, where the Ok() is the type which should be returned, else print error and return #[macro_export] macro_rules! check_result_return { ($v:expr) => { match $v { Ok(t) => t, Err(msg) => { println!("{}", msg); return; } } }; } // check result macro, where the Ok() is void #[macro_export] macro_rules! check_error { ($v:expr) => { if let Err(msg) = $v { return Err(msg); }; }; } /// check result macro, where the Ok() is void, but just print the error message #[macro_export] macro_rules! display_error { ($v:expr) => { if let Err(msg) = $v { println!("{}", msg); return; }; }; } macro_rules! print_error { ($v:expr) => { if let Err(msg) = $v { println!("{}", msg); }; }; }