From: Brendan Hansen Date: Mon, 22 May 2023 20:53:30 +0000 (-0500) Subject: switch branches X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=f5f8bfbac8df75d6488011aa84c255212a11d168;p=onyx.git switch branches --- diff --git a/tests/tagged_unions.onyx b/tests/tagged_unions.onyx index 4c38897e..6b3a17a8 100644 --- 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)?); }