Answers for "loop in rust"

5

for loops in rust

for x in 0..10 {
    println!("{}", x); // x: i32
}

//abstract:
for var in expression {
    code
}
Posted by: Guest on July-26-2020
0

loop in rust

#![allow(unused_variables)]
fn main() {
let mut x = 5; // mut x: i32
let mut done = false; // mut done: bool

while !done {
    x += x - 3;

    println!("{}", x);

    if x % 5 == 0 {
        done = true;
    }
}
}
Posted by: Guest on June-05-2020

Browse Popular Code Answers by Language