macro_rules! duplicate_for_bool{
{
$dollar:tt $placeholder:ident
$($rest:tt)*
} => {
macro_rules! is_placeholder {
{
$dollar caller:tt
input = [{ $dollar body:tt }]
} => {
tt_equal::tt_equal! {
$dollar caller
input = [{ $placeholder $dollar body }]
}
}
}
mod for_true{
tt_call::tt_call! {
macro = [{ tt_call::tt_replace }]
condition = [{ is_placeholder }]
replace_with = [{ true }]
input = [{ $($rest)* }]
}
}
mod for_false{
tt_call::tt_call! {
macro = [{ tt_call::tt_replace }]
condition = [{ is_placeholder }]
replace_with = [{ false }]
input = [{ $($rest)* }]
}
}
};
}
duplicate_for_bool! {
$some_placeholder
pub const BOOL: bool = some_placeholder;
}
#[test]
fn test_duplicate() {
assert!(for_true::BOOL);
assert!(!for_false::BOOL);
}