Lesson 4 - Operators

Rust supports:

+ addition - subtraction * multiplication / division % remainder

For example:

let a = 10;
let b = 3;

println!("{}", a + b);
println!("{}", a - b);
println!("{}", a * b);
println!("{}", a / b);
println!("{}", a % b);

The results are:

13 7 30 3 1

Notice that 10/3 produces an integer (3) when both values are integers.

Rust also has camparison and logical operators.

Comparison:

== equal != not equal > greater than < less than >= greater than or equal <= less than or equal

Logical:

&& AND

|| OR

! NOT