You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.0 KiB
61 lines
1.0 KiB
#![allow(unused_macros)]
|
|
|
|
/// Run something as async or or depending on feature flag `parallel`
|
|
macro_rules! sync
|
|
{
|
|
(if {$($if:tt)*} else {$($else:tt)*}) => {
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(feature="parallel")] {
|
|
$($if)*
|
|
} else {
|
|
$($else)*
|
|
}
|
|
}
|
|
};
|
|
|
|
(if {$($if:tt)*}) => {
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(feature="parallel")] {
|
|
$($if)*
|
|
}
|
|
}
|
|
};
|
|
|
|
(else {$($if:tt)*}) => {
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(not(eature="parallel"))] {
|
|
$($if)*
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export] macro_rules! reyre {
|
|
(m {$($body:tt)*} $lit:literal $($tt:tt)*) => {
|
|
{
|
|
let cls = move || {
|
|
$($body)*
|
|
};
|
|
$crate::reyre!{
|
|
cls(), $lit $($tt)*
|
|
}
|
|
}
|
|
};
|
|
({$($body:tt)*} $lit:literal $($tt:tt)*) => {
|
|
{
|
|
let cls = || {
|
|
$($body)*
|
|
};
|
|
$crate::reyre!{
|
|
cls(), $lit $($tt)*
|
|
}
|
|
}
|
|
};
|
|
($expr:expr, $lit:literal $($tt:tt)*) => {
|
|
{
|
|
use ::color_eyre::eyre::WrapErr;
|
|
$expr.wrap_err_with(|| ::color_eyre::eyre::eyre!($lit $($tt)*))
|
|
}
|
|
}
|
|
}
|