From bd51b09ad68de93a713ae67cc7a4385ee26a3560 Mon Sep 17 00:00:00 2001 From: copygirl Date: Fri, 8 Sep 2023 15:37:17 +0200 Subject: [PATCH] Swap order of EntityPart.id and .name --- src/path.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/path.zig b/src/path.zig index 8234099..c63660c 100644 --- a/src/path.zig +++ b/src/path.zig @@ -23,8 +23,8 @@ pub const Path = struct { /// Represents an `Entity` in a `Path`, either by name or its numeric id. pub const EntityPart = union(enum) { - name: []const u8, id: u32, + name: []const u8, }; /// Format used to parse and stringify `Path`s. @@ -265,8 +265,8 @@ pub const Path = struct { if (first.absolute != second.absolute) return false; if (first.parts.len != second.parts.len) return false; for (first.parts, second.parts) |a, b| switch (a) { - .name => |a_name| if (b != .name or !std.mem.eql(u8, a_name, b.name)) return false, .id => |a_id| if (b != .id or a_id != b.id) return false, + .name => |a_name| if (b != .name or !std.mem.eql(u8, a_name, b.name)) return false, }; return true; } @@ -282,8 +282,8 @@ pub const Path = struct { // Parts themselves. for (self.parts) |part| result += switch (part) { - .name => |name| name.len, .id => |id| numDigits(id), + .name => |name| name.len, }; return result; } @@ -296,15 +296,15 @@ pub const Path = struct { } // Write the first part. switch (self.parts[0]) { - .name => |name| try writer.writeAll(name), .id => |id| try writer.writeIntNative(u32, id), + .name => |name| try writer.writeAll(name), } // Write the remaining parts, each preceeded bu separator. for (self.parts[1..]) |part| { try writer.writeAll(opt.sep); switch (part) { - .name => |name| try writer.writeAll(name), .id => |id| try writer.writeIntNative(u32, id), + .name => |name| try writer.writeAll(name), } } }