forked from verus-lang/verus
verus source docs guide src spec-operator-precedence.md
4.2 kB · 31 lines
Markdown

Operator Precedence #

The table below defines operator precedence from tightest-binding (top) to loosest-binding (bottom).

Operator Associativity Grammar
Binds tighter
. -> left
has, is, matches left V@[has_expr] V@[is_expr] V@[matches_expr]
* / % left V@[arith_expr]
+ - left V@[arith_expr]
<< >> left V@[bit_expr]
& left V@[bit_expr]
^ left V@[bit_expr]
| left V@[bit_expr]
!== == != <= < >= > requires parentheses V@[equality_expr] V@[ineq_expr]
&& left V@[and_expr]
|| left V@[or_expr]
==> right V@[implies_expr]
<== left V@[explies_expr]
<==> requires parentheses V@[iff_expr]
.. left
= right
closures; forall, exists; choose right V@[forall_expr] V@[exists_expr] V@[choose_expr]
&&& left V@[prefix_and_expr]
||| left V@[prefix_or_expr]
Binds looser

All operators that are from ordinary Rust have the same precedence-ordering as in ordinary Rust. See also the Rust operator precedence.