Skip to main content

Operators

Operator precedence below is listed from highest binding (grouped first) to lowest. Operators on the same row bind at the same level; left-associative means a op b op c groups as (a op b) op c.

Unary (prefix), tightest common prefix level

OperatorMeaning
+Unary plus
-Unary minus
!Logical not
~Bitwise not

Multiplicative (left)

*, /, %

Additive (left)

+, -

Shifts (left)

<<, >>

Relational (left)

<, <=, >, >=

Equality (left)

==, !=

Bitwise AND (left)

&

Bitwise XOR (left)

^

Bitwise OR (left)

|

The | operator is also used in pipe-style expression chains when regex/division ambiguity does not apply, e.g.:

new_stream = old_stream | map(x -> x + 1) | filter(x -> x > 0)

Logical AND (left)

&&

Logical OR (left)

||

Conversions

Postfix .into() and .into(TargetType) apply after the above binary and unary structure.

  • .into(Type) — explicit conversion to Type. The compiler checks that a from or into conversion clause exists between the source and target types and emits the canonical conversion function call.
  • .into() — implicit conversion; the compiler infers Type from the expected type in context (assignment, parameter, return). If the target type is ambiguous, use the explicit form.

If expression

Conditional expressions use Rust-style if syntax and may appear anywhere an expression is expected:

if (condition) { then_expr } else { else_expr }

else if chains are supported:

if (x > 10) { "high" } else if (x > 0) { "low" } else { "zero" }

An else branch is required when the if expression is used in a value position (i.e. its result is assigned or returned).

Optional chaining

The ? postfix operator enables null-safe access. Three forms are available:

SyntaxMeaning
expr?.fieldNull-safe field access
expr?[index]Null-safe index access
expr?(args)Null-safe call

Note: ?. is only used for member access (expr?.field). For optional calls and indexing, use ?( and ?[ directly without the dot.

Closures vs match

  • -> starts a closure body after parameters (and optional return type).
  • => separates each match pattern from its result expression.

Summary ordering (high to low)

Unary + - ! ~* / %+ - → shifts → relational → == !=&^|&&||.into() conversions.