use std::fmt::Arguments;
pub fn make_err(fmt: Arguments) -> anyerror::AnyError {
anyerror::AnyError::error(format!("{fmt}"))
}
#[macro_export]
macro_rules! be_true {
($($call: ident).+()) => {{
let __result = $($call).+();
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}() at {}:{}",
stringify!($($call).+),
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr)) => {{
let __a = $a;
let __result = $($call).+(__a);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr, $b: expr)) => {{
let __a = $a;
let __b = $b;
let __result = $($call).+(__a, __b);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?}), {}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
stringify!($b),
__b,
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr, $b: expr, $c: expr)) => {{
let __a = $a;
let __b = $b;
let __c = $c;
let __result = $($call).+(__a, __b, __c);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?}), {}({:?}), {}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
stringify!($b),
__b,
stringify!($c),
__c,
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr, $b: expr, $c: expr, $d: expr)) => {{
let __a = $a;
let __b = $b;
let __c = $c;
let __d = $d;
let __result = $($call).+(__a, __b, __c, __d);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?}), {}({:?}), {}({:?}), {}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
stringify!($b),
__b,
stringify!($c),
__c,
stringify!($d),
__d,
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr, $b: expr, $c: expr, $d: expr, $e: expr)) => {{
let __a = $a;
let __b = $b;
let __c = $c;
let __d = $d;
let __e = $e;
let __result = $($call).+(__a, __b, __c, __d, __e);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
stringify!($b),
__b,
stringify!($c),
__c,
stringify!($d),
__d,
stringify!($e),
__e,
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr, $b: expr, $c: expr, $d: expr, $e: expr, $f: expr)) => {{
let __a = $a;
let __b = $b;
let __c = $c;
let __d = $d;
let __e = $e;
let __f = $f;
let __result = $($call).+(__a, __b, __c, __d, __e, __f);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
stringify!($b),
__b,
stringify!($c),
__c,
stringify!($d),
__d,
stringify!($e),
__e,
stringify!($f),
__f,
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr, $b: expr, $c: expr, $d: expr, $e: expr, $f: expr, $g: expr)) => {{
let __a = $a;
let __b = $b;
let __c = $c;
let __d = $d;
let __e = $e;
let __f = $f;
let __g = $g;
let __result = $($call).+(__a, __b, __c, __d, __e, __f, __g);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
stringify!($b),
__b,
stringify!($c),
__c,
stringify!($d),
__d,
stringify!($e),
__e,
stringify!($f),
__f,
stringify!($g),
__g,
file!(), line!(),
)))?;
}
}};
($($call: ident).+($a: expr, $b: expr, $c: expr, $d: expr, $e: expr, $f: expr, $g: expr, $h: expr)) => {{
let __a = $a;
let __b = $b;
let __c = $c;
let __d = $d;
let __e = $e;
let __f = $f;
let __g = $g;
let __h = $h;
let __result = $($call).+(__a, __b, __c, __d, __e, __f, __g, __h);
if __result {
} else {
Err($crate::macros::make_err(format_args!(
"expect to be true: {}({}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?}), {}({:?})) at {}:{}",
stringify!($($call).+),
stringify!($a),
__a,
stringify!($b),
__b,
stringify!($c),
__c,
stringify!($d),
__d,
stringify!($e),
__e,
stringify!($f),
__f,
stringify!($g),
__g,
stringify!($h),
__h,
file!(), line!(),
)))?;
}
}};
}
#[macro_export]
macro_rules! less {
($a: expr, $b: expr) => {{
let a = $a;
let b = $b;
if (a < b) {
} else {
Err($crate::macros::make_err(format_args!(
"expect: {}({:?}) < {}({:?}) at {}:{}",
stringify!($a),
a,
stringify!($b),
b,
file!(),
line!(),
)))?;
}
}};
}
#[macro_export]
macro_rules! greater {
($a: expr, $b: expr) => {{
let a = $a;
let b = $b;
if (a > b) {
} else {
Err($crate::macros::make_err(format_args!(
"expect: {}({:?}) > {}({:?}) at {}:{}",
stringify!($a),
a,
stringify!($b),
b,
file!(),
line!(),
)))?;
}
}};
}
#[macro_export]
macro_rules! less_equal {
($a: expr, $b: expr) => {{
let a = $a;
let b = $b;
if (a <= b) {
} else {
Err($crate::macros::make_err(format_args!(
"expect: {}({:?}) <= {}({:?}) at {}:{}",
stringify!($a),
a,
stringify!($b),
b,
file!(),
line!(),
)))?;
}
}};
}
#[macro_export]
macro_rules! greater_equal {
($a: expr, $b: expr) => {{
let a = $a;
let b = $b;
if (a >= b) {
} else {
Err($crate::macros::make_err(format_args!(
"expect: {}({:?}) >= {}({:?}) at {}:{}",
stringify!($a),
a,
stringify!($b),
b,
file!(),
line!(),
)))?;
}
}};
}
#[macro_export]
macro_rules! equal {
($a: expr, $b: expr) => {{
let a = $a;
let b = $b;
if (a == b) {
} else {
Err($crate::macros::make_err(format_args!(
"expect: {}({:?}) == {}({:?}) at {}:{}",
stringify!($a),
a,
stringify!($b),
b,
file!(),
line!(),
)))?;
}
}};
}