summaryrefslogtreecommitdiff
path: root/util/aoc.zig
blob: 0f32c54f0aef7b7a469438e9236a5d7f7a88733c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const std = @import("std");

pub const Result = union(enum) {
    int: i64,
    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 => {},
        }
    }
};