Operators
Type-Level Precedence
Tightest first:
T[N]— postfix repetition...T— prefix spreadT<...>— generic application&— product|— union
So A | B & C[3] parses as A | (B & (C[3])).
Expression-Level Precedence
Tightest first:
.— method call / field access()— function application?— postfix error propagation&— value-level product (only inside a constructor argument)
So foo.bar()? is ((foo.bar)())?.
Glossary of Operators and Sigils
| Symbol | Meaning |
|---|---|
| | Union |
& | Product |
Type[N] | Fixed repetition (N copies) |
...Type | Unbounded repetition |
<T> | Generic parameter |
<T: Tr> | Generic with trait constraint |
::<T> | Type argument at a call site (turbofish) |
. | Method call / field access |
? | Propagate Result / Option failure |
*name | Private method (file-local) |
"..." | String literal sugar |
mut | Mutable parameter |
::<T> after a method name pins a generic method's type parameter when
the compiler cannot infer it from context:
Json.parse::<List<Int>>("[1, 2, 3]")?