macro ct-for

macro to repeat code multiple times with different substitutions

2 releases

0.1.1 Feb 16, 2022
0.1.0 Feb 16, 2022

#1392 in Development tools

MIT license

7KB
96 lines

ct-for

license crates.io ci docs.rs

This crate exposes the ct-for!() macro, which can be used to repeat code n times with a substitution.

For example:

let c = 17;
ct_for!(x in ["5", 6, c, vec![5, 6, 7]] do
    println!("{:?}", x);
);

expands to:

let c = 17;
println!("{:?}", "5");
println!("{:?}", 6);
println!("{:?}", c);
println!("{:?}", vec![5, 6, 7]);

The ct_for!() macro can also be nested.

There really isn't much more to it.

Dependencies

~76KB