authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-04-28 18:39:39 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-04-28 18:40:00 -07:00
log4ddb283ecc975d6d9aae9177d0423de2946ce58e
tree58807ad03edb3ee24c526c2557ed182ee08bb083
parentca1b8dcc2891fc1b344e8d602cc593694a1e5008

add Object.Id.erase() to get the underlying Id regardless of Type


1 files changed, 7 insertions(+), 0 deletions(-)

git.zig+7
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1const std = @import("std");1const std = @import("std");
2const string = []const u8;2const string = []const u8;
3const top = @This();
34
4// 40 is length of sha1 hash5// 40 is length of sha1 hash
5pub const Id = *const [40]u8;6pub const Id = *const [40]u8;
...@@ -147,6 +148,12 @@ pub const Tree = struct {...@@ -147,6 +148,12 @@ pub const Tree = struct {
147 commit: CommitId,148 commit: CommitId,
148149
149 pub const Tag = std.meta.Tag(@This());150 pub const Tag = std.meta.Tag(@This());
151
152 pub fn erase(self: @This()) top.Id {
153 return switch (self) {
154 inline else => |v| v.id,
155 };
156 }
150 };157 };
151158
152 pub const Mode = struct {159 pub const Mode = struct {