Tuples
Tuples group multiple values. Tuple types are written as (T1, T2, ...).
Multiple Values
Section titled “Multiple Values”Destructuring bindings can choose mutability:
The parentheses introduce destructuring, including the one-binding form. By-value bindings keep a type position; borrowed bindings may omit it:
Tuple patterns use the same recursive shape in is, switch, enum payloads, and optional payloads.
One payload tuple layer is supplied directly to the variant:
One-element Tuples
Section titled “One-element Tuples”(T) is equivalent to T:
Accordingly, (ref value) = source; borrows source directly; it does not project an index 0.
Void is the zero-size type; () is its only value:
Void can be used as a parameter, local, and field type.
Destructuring in Loops
Section titled “Destructuring in Loops”for in binds one pattern before in. Destructure tuples inside the loop body: