Skip to content

Instantly share code, notes, and snippets.

@rashaabdulrazzak
Created January 7, 2022 12:27
Show Gist options
  • Save rashaabdulrazzak/22fc99abbe7ae75c3bc0a33c9057f21b to your computer and use it in GitHub Desktop.
Save rashaabdulrazzak/22fc99abbe7ae75c3bc0a33c9057f21b to your computer and use it in GitHub Desktop.
loop in rust
fn main (){
//define a for loop
for i in 0..3 {
println!("{}", i);
}
// define while loop
let mut x = 3;
while (x > 0){
x -= 1 ;
println!("{}", x);
}
// define loop
// this will be infintie if we don't put a condition
//define an integer variable
let mut var = 1;
// define a while loop
loop {
var = var + 1;
println!("{}", var);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment