Appendix B — Operator Reference
Reserved for the second edition. The exhaustive operator + precedence reference will land here once the upcoming language audit completes.
Until then, a quick overview of what the chapters have introduced.
Arithmetic
+, -, *, /, % — addition, subtraction, multiplication, division, modulo. Bind in the conventional order; parentheses disambiguate.
Comparison
==, !=, <, <=, >, >= — equality, inequality, ordering. Both sides can be expressions over bound variables and constants.
Logical / set membership
not <atom> — negation as failure. ?x in <collection> — set membership at rule-atom position. At expression position, x in xs and x not in xs desugar to <TypeOf(xs)>::contains(xs, x) (and its negation).
Collection operators
The collection-op surface is grounded in Chapter 2.8. All forms desugar at elaboration time to qualified calls into the receiver’s std::collection::* (or std::math::Range) submodule.
| Token | Form | Fixity | Precedence | Desugar | Example |
|---|---|---|---|---|---|
. | xs.m(args) | postfix | tightest (binds before any binary op) | <TypeOf(xs)>::m(xs, args) | b.units.size() |
[i] | xs[i] | postfix | tightest | <TypeOf(xs)>::at(xs, i) (or Map::get) | b.units[0] |
[i..j] / [i..] / [..j] | slicing | postfix | tightest | <TypeOf(xs)>::slice(xs, Range::new(i, j)) | b.units[0..3] |
.. | range literal | binary infix | below + / -, above comparison | Range::new(lo, hi) (half-open) | 0..10 |
..= | inclusive range literal | binary infix | same as .. | Range::inclusive(lo, hi) | 0..=9 |
in | membership | binary infix | same precedence as comparison (==, <, …) | <TypeOf(xs)>::contains(xs, x) | p in b.tenants |
not in | non-membership | binary infix | same as in | not <TypeOf(xs)>::contains(xs, x) | p not in b.tenants |
[expr for x in xs where pred] | comprehension | bracket form | bracket-bounded | xs.filter(<pred>).map(<expr-as-closure>) | [u.number for u in b.units] |
Comprehensions reuse the aggregate-binding subgrammar. The where clause is optional. Binder shadowing emits OW2403.
Path
a.b.c — field-access path on a value. ?x.b.c — Datalog-binding-position field-access path on a variable.
Cardinality (inside collection types)
>= N, == N, <= N — at-least / exactly / at-most cardinality clauses. Distinct from comparison operators despite sharing tokens.
Type tests / subtype tests
v: T — match-arm type test (also a rule-atom shape). ?x specializes T — subtype predicate (rule-body only). ?x : T — rule-atom typed-binding form.
Modal operators
box(...) — necessity. diamond(...) — possibility. Rule-atom position.
Allen-interval operators
before, after, meets, met_by, overlaps, overlapped_by, starts, started_by, during, contains, finishes, finished_by, equals — interval-relations algebra binary infix operators.
Quantifiers
forall <var>: <T> [where <body>], exists <var>: <T> [where <body>] — restriction and binding forms; tier-classified.
Aggregation
sum, count, min, max, avg — fold-style aggregates over for var in path [where atom].
Module path
:: — module-qualified path separator. pkg::mod::Item.
Rule arrows
:- — body separator. => — consequence (rules) and arm body (match arms). Context disambiguates.
Membership / subtype-by-pattern
The full set is documented in the per-crate API documentation.