toml
[dependencies]
loop_chain = "0.1.0-beta"
rust
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:
rust
fn main() {
for width in 0..10 {
for height in 0..10 {
println!("width: {}, height: {}", width, height);
}
}
}
```rust fn main() { let mut foo = 0; loopchain::loopchain! { while foo < 3; foo += 1; for x in 0..10; then { println!("foo: {}, x: {}", foo, x); } } }
```
the generated code will be the following:
rust
fn main() {
let mut foo = 0;
while foo < 3 {
for x in 0..10 {
println!("foo: {}, x: {}", foo, x);
}
}
}
rust
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:
rust
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);
}
}
}
rust
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:
rust
fn main() {
let mut foo = 0;
loop {
foo += 1;
if foo > 3 {
break
};
for x in 0..10 {
println!("foo: {}, x: {}", foo, x);
}
}
}