Rust Cheat Sheet
Rust Cheat Sheet
Rust Cheat Sheet
let x = 5; if count == 5 {
if x > 0 { println!("OK, that's enough");
println!("x is positive");
} else { // Exit this loop
println!("x is non-positive"); break;
} }
}
2.while-> }
let mut x = 0;
while x < 10 {
println!("x is {}", x); for loop-
x += 1;
} let fruits = ["apple", "banana", "orange"];
for fruit in fruits {
3.match-> println!("{}", fruit);
}
let x = 5;
match x {
0 => println!("x is zero"),
1...5 => println!("x is between 1 and 5"), Function-A function is a block of code that
_ => println!("x is something else"), performs a specific task and can be called
} by name.