mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 15:40:03 +08:00
feat: add opt_result
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#[macro_use] extern crate rust_util;
|
||||
|
||||
use rust_util::XResult;
|
||||
use rust_util::{XResult, SimpleError};
|
||||
|
||||
// cargo run --example log
|
||||
fn main() -> XResult<()> {
|
||||
@@ -18,5 +18,12 @@ error or ^"##);
|
||||
warning!("Hello {}", "world!");
|
||||
failure!("Hello {}", "world!");
|
||||
|
||||
println!("{:?}", test_opt_result());
|
||||
|
||||
simple_error!("helloworld {}", 1)
|
||||
}
|
||||
}
|
||||
|
||||
fn test_opt_result() -> XResult<()> {
|
||||
let a = Err(SimpleError::new("test".into()));
|
||||
opt_result!(a, "error: {}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user