projects
/
onyx.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7ff7b91
)
switch branches
author
Brendan Hansen
<brendan.f.hansen@gmail.com>
Mon, 22 May 2023 20:53:30 +0000
(15:53 -0500)
committer
Brendan Hansen
<brendan.f.hansen@gmail.com>
Mon, 22 May 2023 20:53:30 +0000
(15:53 -0500)
tests/tagged_unions.onyx
patch
|
blob
|
history
diff --git
a/tests/tagged_unions.onyx
b/tests/tagged_unions.onyx
index 4c38897ec86e70169d0efe37ab79ed6c2f69f6c6..6b3a17a82ad2083c6982eb37a3150060fc47a080 100644
(file)
--- a/
tests/tagged_unions.onyx
+++ b/
tests/tagged_unions.onyx
@@
-1,6
+1,10
@@
use core {*}
+union_is :: macro (u: $U, $variant: U.tag_enum) -> bool {
+ return cast(U.tag_enum, u) == variant;
+}
+
extract_variant :: macro (u: $U, $variant: U.tag_enum) => {
switch u {
case variant => v {
@@
-57,7
+61,7
@@
simple_test :: () {
call_test(u);
- if
cast(SimpleUnion.tag_enum, u) == .b
{
+ if
union_is(u, .b)
{
println(extract_variant(u, .b)?);
}