Rust Operators

In the Rust programming language, an operator is a symbol that performs an operation on one or more values.

Operators act on one or more operands and produce an output based on their operation.

Rust has many operators that perform useful functions. Operators can be classified based on how they work; there are arithmetic operators, logical operators, comparison operators, bitwise operators, and more.

Operators that act on a single operand are called unary operators, while operators that act on two operands are called binary operators.

Unary Operators

Unary operators act on a single operand. Examples of unary operators include:

  • Negation
  • Dereference
  • Borrow

Binary Operators

Binary operators act on two operators. Examples of binary operators include: