use include_tt::inject;
use std::fmt::Write;
macro_rules! test2_rules {
[
[a, b]
$($tt:tt)*
] => {
println!("test2_rules: [a, b]");
test2_rules! {
$($tt)*
}
};
[
[c, d]
$($tt:tt)*
] => {
println!("test2_rules: [c, d]");
test2_rules! {
$($tt)*
}
};
[
a, b
$($tt:tt)*
] => {
println!("test2_rules: a, b");
test2_rules! {
$($tt)*
}
};
[
$($tt:tt)+
] => {
compile_error!(stringify!( $($tt)* ))
};
[] => []
}
fn main() {
inject! {
#POINT_TRACKER_FILES:
test2_rules! {
[ #tt("./examples/full.tt") ] [ #tt { "./examples/full.tt" } ] }
test2_rules! {
#tt ("./examples/full.tt") }
println!(
concat!(
"#",
#str("./examples/full.tt"), "#"
)
);
}
{
let str = inject!(#str("./examples/full.tt")); assert_eq!(str, "a, b");
}
{
let array: &'static [u8; 4] = inject!(
#array("./examples/full.tt") );
assert_eq!(array, b"a, b");
}
{
let a = 10;
let b = 20;
let mut end_str = String::new();
inject! {
let _e = write!(
&mut end_str,
"arg1: {}, arg2: {}",
#tt("./examples/full.tt") );
}
assert_eq!(end_str, "arg1: 10, arg2: 20");
}
}