Operators
Arithmetic Operators
+: Addition — returns the sum of two operands.-: Subtraction — returns the difference between two operands.*: Multiplication — returns the product of two operands./: Division — returns the quotient of two operands.%: Modulo (remainder) — returns the remainder after division.
Comparison Operators
==: Equality — checks if two values are equal.!=: Inequality — checks if two values are not equal.<: Less than — checks if the left operand is smaller.>: Greater than — checks if the left operand is larger.<=: Less than or equal to — checks if the left operand is smaller or equal.>=: Greater than or equal to — checks if the left operand is larger or equal.
Logical Operators
&&: Logical AND — returnstrueonly if both operands aretrue.||: Logical OR — returnstrueif at least one operand istrue.!: Logical NOT — inverts the boolean value of its operand.
Bitwise Operators
&: Bitwise AND — performs a bitwise AND on each bit.|: Bitwise OR — performs a bitwise OR on each bit.^: Bitwise XOR — performs a bitwise exclusive OR on each bit.!: Bitwise NOT — inverts all bits in the operand.<<: Left shift — shifts bits to the left by the specified amount.>>: Right shift — shifts bits to the right by the specified amount.
Compound Assignment Operators
+=: Addition assignment — adds the right operand to the left and assigns the result.-=: Subtraction assignment — subtracts the right operand from the left and assigns the result.*=: Multiplication assignment — multiplies the left operand by the right and assigns the result./=: Division assignment — divides the left operand by the right and assigns the result.%=: Modulo assignment — computes the remainder and assigns the result.&=: Bitwise AND assignment — performs bitwise AND and assigns the result.|=: Bitwise OR assignment — performs bitwise OR and assigns the result.^=: Bitwise XOR assignment — performs bitwise XOR and assigns the result.<<=: Left shift assignment — shifts left and assigns the result.>>=: Right shift assignment — shifts right and assigns the result.
Other Key Operators and Symbols
.: Field access or method call — accesses a field or calls a method on an object...: Right-exclusive range literal — creates a range from start to end (exclusive)...=: Right-inclusive range literal — creates a range from start to end (inclusive)...: Struct literal update syntax — updates a struct with new values...: “And the rest” pattern binding — matches remaining fields in a pattern.?: Error propagation — unwraps aResultorOption, propagating errors.&: Borrowing — creates a shared reference (&T) or mutable reference (&mut T).*: Dereference — accesses the value pointed to by a pointer.as: Type casting — converts a value from one type to another.:: Type annotation — specifies the type of a variable or expression.;: Statement terminator — ends a statement or item.->: Function return type — specifies the return type of a function or closure.@: Pattern binding — binds a name to a matched value in a pattern.