Skip to content

st4s1k/rust-c4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

c4

Rust C-like for-loop macro.

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);
        }
    }
}