...

/

Precedence and Associativity

Precedence and Associativity

This lesson discusses two important characteristics of operators - precedence and associativity.

Precedence

The precedence of an operator determines which operation is performed first in an expression with more than one operators.

Operators are listed below in the order of their precedence from highest to lowest :

  • Unary
    • Logical/Bitwise NOT - !
    • Derereference - *
    • Borrow - &, &mut
  • Binary
    • Typecast - as
    • Multiplication- *,Division - /, Remainder - %
    • Addition -+,
...