2023-12-06 18:48:38 +00:00
|
|
|
================================================================================
|
|
|
|
Match Values
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
match x {
|
|
|
|
1 => {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
2 => false
|
|
|
|
}
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(root
|
|
|
|
(statement
|
2024-02-16 15:55:15 +00:00
|
|
|
(statement_kind
|
|
|
|
(match
|
2023-12-06 18:48:38 +00:00
|
|
|
(expression
|
2024-02-16 15:55:15 +00:00
|
|
|
(identifier))
|
|
|
|
(match_pattern
|
|
|
|
(value
|
|
|
|
(integer)))
|
|
|
|
(statement
|
|
|
|
(statement_kind
|
|
|
|
(block
|
|
|
|
(statement
|
|
|
|
(statement_kind
|
|
|
|
(expression
|
|
|
|
(value
|
|
|
|
(boolean))))))))
|
|
|
|
(match_pattern
|
2023-12-06 18:48:38 +00:00
|
|
|
(value
|
2024-02-16 15:55:15 +00:00
|
|
|
(integer)))
|
|
|
|
(statement
|
|
|
|
(statement_kind
|
|
|
|
(expression
|
|
|
|
(value
|
|
|
|
(boolean)))))))))
|
2024-02-15 12:04:38 +00:00
|
|
|
|
|
|
|
================================================================================
|
|
|
|
Match Enum
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
match foobar {
|
|
|
|
FooBar::Foo => true
|
|
|
|
FooBar::Bar => false
|
|
|
|
}
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(root
|
|
|
|
(statement
|
2024-02-16 15:55:15 +00:00
|
|
|
(statement_kind
|
|
|
|
(match
|
2024-02-15 12:04:38 +00:00
|
|
|
(expression
|
2024-02-16 15:55:15 +00:00
|
|
|
(identifier))
|
|
|
|
(match_pattern
|
|
|
|
(enum_pattern
|
|
|
|
(identifier)
|
|
|
|
(identifier)))
|
|
|
|
(statement
|
|
|
|
(statement_kind
|
|
|
|
(expression
|
|
|
|
(value
|
|
|
|
(boolean)))))
|
|
|
|
(match_pattern
|
|
|
|
(enum_pattern
|
|
|
|
(identifier)
|
|
|
|
(identifier)))
|
|
|
|
(statement
|
|
|
|
(statement_kind
|
|
|
|
(expression
|
|
|
|
(value
|
|
|
|
(boolean)))))))))
|