micro test_class_pattern(p: Point) {
match p {
case Point { x: 0, y: 0 }: "origin";
case Point { x, y }: "point at ({x}, {y})";
else: "unknown"
}
}
micro test_mixed_pattern(person: Person) {
match person {
case Person { name: "Alice", age }: "Alice is {age} years old";
case Person { name, age: 18 }: "{name} is 18 years old";
case Person { name, age }: "{name} is {age} years old";
else: "unknown person"
}
}
micro test_nested_pattern(container: Container) {
match container {
case Container { inner: Inner { a: 0, b } }: "inner a is zero, b is {b}";
case Container { inner: Inner { a, b } }: "inner ({a}, {b})";
else: "other"
}
}