Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Spec index operator []

Syntax

spec_index_expr ::= spec_expr [ spec_expr ]

Desugaring

In spec code, the expression expr[i] desguars to expr.spec_index(i), which is resolved as normal via Rust’s method resolution.

Verus/Rust difference

This is different than the index operator in executable code, where it is either a place expression indexing into a slice or an array, or is overloaded via the Index or IndexMut traits.

Use cases

For example: