1
0
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:
2021-04-30 23:01:35 +08:00
parent 6ed6a9d26f
commit b91e6e060a
3 changed files with 24 additions and 5 deletions

View File

@@ -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: {}")
}