Spec §A — Appendix
A.1 Operator precedence
Tightest to loosest; binary levels are left-associative (§3.7):
| Level | Operators |
|---|---|
| 1 | :: paths · calls · .member · [index] · ! (try) · ?. |
| 2 | prefix ! - await async & &mut * |
| 3 | * / % |
| 4 | + - |
| 5 | << >> (span-adjacent) |
| 6 | & |
| 7 | ^ |
| 8 | | |
| 9 | == != < <= > >= |
| 10 | is |
| 11 | && |
| 12 | || |
Above level 12 sit the expression forms (closures, blocks, if,
match, for, let, ret, assignment), and above those the
top-tier-only forms: const expr and struct initializers (§3.8).
A.2 Reserved words
async await borrows const else enum export external
for fun if impl import in is jump
let macro match mod mut null own resource
ret struct trait type use with true false
Contextual (identifier everywhere else): context, sync, void,
self, Self, break/continue (after jump), and the attribute names
derive service extern must_use rpc trait_only doc
expose platform deprecated.
A.3 Literal suffixes
i8 i16 i32 i53 u8 u16 u32 u53 f f32 f64 n: §2.3 (unknown suffixes
error; i64/u64 were renamed to i53/u53). Unsuffixed: integer
→ i32, fractional → f64.
A.4 Lang items
Std declarations the language itself depends on:
The prelude column says whether the default (base) prelude makes the
name ambient too — Option is both a lang item and a prelude member, and
that is where the two ideas meet (§4.7). built-in means the language
has it with no prelude at all.
| Item | Module | Language use | Prelude |
|---|---|---|---|
primitives (bool, str, numerics, BigInt) | std::boolean/string/number | literal types | built-in |
List<T> | std::list | list literals, for | built-in |
Option<T> | std::option | ?. results, view-returning lookups | base (with Some/None) |
Try, Verdict, Lift | std::operators | !, ?. (§5.10) | — (but Result/Ok/Err are base) |
Add Sub Mul Div Rem Shl Shr BitAnd BitOr BitXor | std::operators | operators (§5.7) | — |
PartialEq, PartialOrd | std::compare | ==/ordering (§5.7) | — |
Iterator/Iterable | std::iterator | for … in | — |
Task<T> | std::task | async/await (§7.3) | — |
Promise<T> | std::promise | host-interop promises (§7.3) | — |
Context<T> | std::context | contexts (§8) | — |
panic, assert | std::io | divergence, vilan test | — |