Alias Pattern
Any pattern can be bound to an extra new name via an alias pattern. The syntax is pattern as name
. In this example, we use this feature to preserve the original tuples while pattern matching them.
fn main {
let (a, (b, _) as tuple, _) as triple = (1, (true, 5), false)
println("a: \{a}, b: \{b}")
println("tuple: \{tuple}")
println("triple: \{triple}")
}