summaryrefslogtreecommitdiff
path: root/util/aoc.zig
diff options
context:
space:
mode:
Diffstat (limited to 'util/aoc.zig')
-rw-r--r--util/aoc.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/util/aoc.zig b/util/aoc.zig
new file mode 100644
index 0000000..0c3e668
--- /dev/null
+++ b/util/aoc.zig
@@ -0,0 +1,20 @@
+const std = @import("std");
+
+pub const Result = union(enum) {
+ int: i32,
+ string: []const u8,
+
+ pub fn cmp(self: Result, result: Result) bool {
+ switch (self) {
+ .int => |i| return i == result.int,
+ .string => |s| return std.mem.eql(u8, s, result.string),
+ }
+ }
+
+ pub fn deinit(self: Result, allocator: std.mem.Allocator) void {
+ switch (self) {
+ .string => |s| return allocator.free(s),
+ else => {},
+ }
+ }
+};