add mactors for true/false
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
a2e5c3d5d3
commit
4485f36e34
2 changed files with 56 additions and 32 deletions
|
@ -38,3 +38,59 @@ pub mod mods {
|
||||||
() => {};
|
() => {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Functor for falsy
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_false {
|
||||||
|
() => {
|
||||||
|
|x| !x
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functor for truthy
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_true {
|
||||||
|
() => {
|
||||||
|
|x| !!x
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functor for equality to zero
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_zero {
|
||||||
|
() => {
|
||||||
|
$crate::is_matching!(0)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functor for equality i.e. .is_some_and(is_equal!(2))
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_equal_to {
|
||||||
|
($val:expr) => {
|
||||||
|
|x| x == $val
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functor for less i.e. .is_some_and(is_less_than!(2))
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_less_than {
|
||||||
|
($val:expr) => {
|
||||||
|
|x| x < $val
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functor for matches! i.e. .is_some_and(is_matching!('A'..='Z'))
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_matching {
|
||||||
|
($val:expr) => {
|
||||||
|
|x| matches!(x, $val)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Functor for !is_empty()
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_not_empty {
|
||||||
|
() => {
|
||||||
|
|x| !x.is_empty()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -53,38 +53,6 @@ macro_rules! validated {
|
||||||
($($input:tt)+) => { $crate::expected!($($input)+) }
|
($($input:tt)+) => { $crate::expected!($($input)+) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Functor for equality to zero
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! is_zero {
|
|
||||||
() => {
|
|
||||||
$crate::is_matching!(0)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Functor for equality i.e. .is_some_and(is_equal!(2))
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! is_equal_to {
|
|
||||||
($val:expr) => {
|
|
||||||
|x| (x == $val)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Functor for less i.e. .is_some_and(is_less_than!(2))
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! is_less_than {
|
|
||||||
($val:expr) => {
|
|
||||||
|x| (x < $val)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Functor for matches! i.e. .is_some_and(is_matching!('A'..='Z'))
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! is_matching {
|
|
||||||
($val:expr) => {
|
|
||||||
|x| matches!(x, $val)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns false if the exponential backoff has expired based on the inputs
|
/// Returns false if the exponential backoff has expired based on the inputs
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue