haar_lib/macros/for_loop.rs
1//! `for_loop!`
2
3/// C言語風のfor文
4#[macro_export]
5macro_rules! for_loop {
6 ($init:stmt; $end:expr; $update:stmt; $b:block) => {
7 #[allow(redundant_semicolons)]
8 {
9 $init;
10 while $end {
11 $b;
12 $update;
13 }
14 }
15 };
16}
17
18#[cfg(test)]
19mod tests {
20 #[test]
21 fn test() {
22 let mut x = 0;
23 for_loop!(x += 1; x < 100; x += 1; {
24 println!("{}", x);
25 });
26 }
27}