https://github.com/rob2309/ct-for-rs
Macro for repeating code several times with substitutions
https://github.com/rob2309/ct-for-rs
Last synced: over 1 year ago
JSON representation
Macro for repeating code several times with substitutions
- Host: GitHub
- URL: https://github.com/rob2309/ct-for-rs
- Owner: Rob2309
- License: mit
- Created: 2022-02-16T09:50:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T09:29:07.000Z (over 3 years ago)
- Last Synced: 2025-03-09T00:47:10.187Z (over 1 year ago)
- Language: Rust
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ct-for

[](https://crates.io/crates/ct-for)
[](https://github.com/Rob2309/ct-for-rs/actions/workflows/ci.yaml)
[](https://docs.rs/ct-for)
This crate exposes the `ct-for!()` macro, which can be used to repeat code `n` times with a substitution.
For example:
```rust
let c = 17;
ct_for!(x in ["5", 6, c, vec![5, 6, 7]] do
println!("{:?}", x);
);
```
expands to:
```rust
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.