23.02 Control Flow
Control Flow
Overview
Control flow in Rust includes conditionals, loops, and pattern matching.
Topics
- if-else Statements
- Loops (loop, while, for)
- break and continue
Examples
if x > 0 {
println!("Positive");
} else {
println!("Non-positive");
}
for i in 0..5 {
println!("{}", i);
}
let mut count = 0;
while count < 5 {
println!("{}", count);
count += 1;
}