Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/st4s1k/rust-c4
Rust macro for C-like for-loop
https://github.com/st4s1k/rust-c4
for for-loop macro macros macros-rust rust rust-crate rust-lang rust-library rustlang
Last synced: 2 months ago
JSON representation
Rust macro for C-like for-loop
- Host: GitHub
- URL: https://github.com/st4s1k/rust-c4
- Owner: st4s1k
- Created: 2024-08-06T21:55:32.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-08-07T20:09:38.000Z (5 months ago)
- Last Synced: 2024-09-29T22:42:29.467Z (3 months ago)
- Topics: for, for-loop, macro, macros, macros-rust, rust, rust-crate, rust-lang, rust-library, rustlang
- Language: Rust
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# c4
Rust C-like for-loop macro.
```rust
fn main() {
c4! {
for (let mut i = 1; i <= 10; i += 1) {
println!("9 * {:<2} = {}{}", i, i - 1, 10 - i);
}
}
c4! {
for (
let (mut i, mut j) = (0, 0),
let mut s = "some dummy word".to_string();
i * j <= s.len();
i += 1,
s = format!("{} {} {}", &s, i, j)
) {
j += 1;
println!("i: {}; j: {}; s: {}", i, j, s);
}
}
}
```