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 β returnsΒtrueΒ only if both operands areΒtrue.||: Logical OR β returnsΒtrueΒ if at least one operand isΒtrue.!: 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 aΒResultΒ orΒOption, 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.