From f5f8bfbac8df75d6488011aa84c255212a11d168 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 22 May 2023 15:53:30 -0500 Subject: [PATCH] switch branches --- tests/tagged_unions.onyx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)?); } -- 2.25.1