Arithmetic, comparison and logical
Operators are short symbols that act on one or more values. Rust groups them into arithmetic (+ - * / %), comparison (== != < > <= >=) and logical (AND OR NOT). Combine them to build the conditions that drive your program.
let (a, b) = (10, 3);
println!("{} {} {}", a + b, a - b, a % b);
println!("{}", a > b && b < 5);Precedence
Just like in maths, * binds tighter than +, so 2 + 3 * 4 is 14, not 20. When in doubt add parentheses — they cost nothing at runtime and make intent clear to anyone reading the code later.
Equality vs assignment
One of the most common beginner bugs is writing = (assignment) when you meant == (comparison). Read your conditions out loud — "if total equals one hundred" — to catch this kind of typo.
Details for rust
Conditions require bool. if is an expression with compatible branch values. match must cover every possibility. Option models absence. Vec grows; get returns Option for checked access while indexing can panic.
Practice and verify
Change one meaningful value in the example and predict the result before running. Then test a boundary or empty value. Explain what changed and why, rather than only copying the output.