Crates.io | loop_chain |
lib.rs | loop_chain |
version | 0.1.1 |
source | src |
created_at | 2021-04-27 08:15:14.553115 |
updated_at | 2021-05-07 18:01:52.23533 |
description | Macro for writing nested Loop expressions |
homepage | https://github.com/TaKO8Ki/loop_chain |
repository | https://github.com/TaKO8Ki/loop_chain |
max_upload_size | |
id | 390070 |
size | 14,280 |
[dependencies]
loop_chain = "0.1.1"
fn main() {
loop_chain::loop_chain! {
for width in 0..10;
for height in 0..10;
then {
println!("width: {}, height: {}", width, height);
}
}
}
the generated code will be the following:
fn main() {
for width in 0..10 {
for height in 0..10 {
println!("width: {}, height: {}", width, height);
}
}
}
fn main() {
let mut foo = 0;
loop_chain::loop_chain! {
while foo < 3;
foo += 1;
for x in 0..10;
then {
println!("foo: {}, x: {}", foo, x);
}
}
}
the generated code will be the following:
fn main() {
let mut foo = 0;
while foo < 3 {
for x in 0..10 {
println!("foo: {}, x: {}", foo, x);
}
}
}
fn main() {
let mut foo = (0..10).collect::<Vec<u8>>();
loop_chain::loop_chain! {
while let Some(v) = foo.pop();
for x in 0..10;
then {
println!("v: {}, x: {}", v, x);
}
}
}
the generated code will be the following:
fn main() {
let mut foo = (0..10).collect::<Vec<u8>>();
while let Some(v) = foo.pop() {
for x in 0..10 {
println!("v: {}, x: {}", v, x);
}
}
}
fn main() {
let mut foo = 0;
loop_chain::loop_chain! {
loop;
foo += 1;
if foo > 3 {
break
};
for x in 0..10;
then {
println!("foo: {}, x: {}", foo, x);
}
}
}
the generated code will be the following:
fn main() {
let mut foo = 0;
loop {
foo += 1;
if foo > 3 {
break
};
for x in 0..10 {
println!("foo: {}, x: {}", foo, x);
}
}
}