mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-29 16:40:05 +08:00
feat: add macro information/success/warning/failure/debugging
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Hatter's Rust Util"
|
description = "Hatter's Rust Util"
|
||||||
|
|||||||
19
src/lib.rs
19
src/lib.rs
@@ -15,13 +15,28 @@ pub mod util_file;
|
|||||||
pub mod util_time;
|
pub mod util_time;
|
||||||
|
|
||||||
/// iff!(condition, result_when_true, result_when_false)
|
/// iff!(condition, result_when_true, result_when_false)
|
||||||
#[macro_export]
|
#[macro_export] macro_rules! iff {
|
||||||
macro_rules! iff {
|
|
||||||
($c:expr, $t:expr, $f:expr) => {
|
($c:expr, $t:expr, $f:expr) => {
|
||||||
if $c { $t } else { $f }
|
if $c { $t } else { $f }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export] macro_rules! information {
|
||||||
|
($($arg:tt)+) => ( crate::util_msg::print_info(&format!($($arg)+)); )
|
||||||
|
}
|
||||||
|
#[macro_export] macro_rules! success {
|
||||||
|
($($arg:tt)+) => ( crate::util_msg::print_ok(&format!($($arg)+)); )
|
||||||
|
}
|
||||||
|
#[macro_export] macro_rules! warning {
|
||||||
|
($($arg:tt)+) => ( crate::util_msg::print_warn(&format!($($arg)+)); )
|
||||||
|
}
|
||||||
|
#[macro_export] macro_rules! failure {
|
||||||
|
($($arg:tt)+) => ( crate::util_msg::print_error(&format!($($arg)+)); )
|
||||||
|
}
|
||||||
|
#[macro_export] macro_rules! debugging {
|
||||||
|
($($arg:tt)+) => ( crate::util_msg::print_debug(&format!($($arg)+)); )
|
||||||
|
}
|
||||||
|
|
||||||
pub type XResult<T> = Result<T, Box<dyn std::error::Error>>;
|
pub type XResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
pub fn new_box_error(m: &str) -> Box<dyn std::error::Error> {
|
pub fn new_box_error(m: &str) -> Box<dyn std::error::Error> {
|
||||||
|
|||||||
Reference in New Issue
Block a user