try abstracting `dir` as a type

leesongun
Nov 5, 2022, 10:00 AM
S3MGNPS5MEGEOUM6FDTSPXIXLVKW3FWOA33KSWDWEVNIRUBOFIAAC

Dependencies

Change contents

  • file addition: dir.zig (----------)
    [2.15]
    pub const Self = enum(u2) {
    left = 0,
    up = 1,
    right = 2,
    down = 3,
    const OPP: u2 = @enumToInt(Self.left) ^ @enumToInt(Self.right);
    pub fn opp(self: Self) Self {
    return @intToEnum(Self, OPP ^ @enumToInt(self));
    }
    pub fn xor(self: Self, other: Self) u2 {
    return @enumToInt(self) ^ @enumToInt(other);
    }
    pub fn sub(self: *Self, other: u2) void {
    self.* = @intToEnum(Self, @enumToInt(self.*) ^ other);
    }
    comptime {
    if (Self.down.opp() != Self.up) @compileError("WRONG");
    }
    };
    pub const arrows = "<^>V";
    pub const pipes = " lqml kxqk jmxj";
    pub usingnamespace Self;