Rob2309 / ct-for-rs

Macro for repeating code several times with substitutions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Macro for repeating code several times with substitutions

License:MIT License


Languages

Language:Rust 100.0%