Pattern matching
Matching in place
switch x! and patterns with !: change the matched value through its pattern instead of copying it.
Mark the subject of a switch with ! and the names in a pattern with ! to change the value in place.
fn main() {
var p = (1, 2)
switch p! {
case (a!, b): a += b
}
print(p)
}(3, 2)Here a! is the first component of p itself, so a += b changes p. The same marks work in for x! of xs; see Ownership.
Related
is
A pattern as a test: if, while and guard with is, binding names for the block, and is in conditions and list builders.
Attributes
Attributes are @name notes before an item: the ones the compiler acts on today (derive, checkfree, inline_always, leaf) and the library's (json), and what happens to an unknown one.