diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-05-20 03:25:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-20 03:25:19 +0100 |
| commit | 23c817548bbd3988a5fd224b590a4f6102dbe5db (patch) | |
| tree | 5448478794cb493b456de356c2e29fb100e81cfb /src/InternPool.zig | |
| parent | f2077f57ae03ef21f1bfee6e4e041c5f466fc3be (diff) | |
| parent | 37a9a4e0f16c1df8de3a4add3a9566b24f024a95 (diff) | |
| download | zig-23c817548bbd3988a5fd224b590a4f6102dbe5db.tar.gz zig-23c817548bbd3988a5fd224b590a4f6102dbe5db.zip | |
Merge pull request #23836 from mlugg/incr-fixes
Incremental fixes, refactor `Zcu.File`
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index d1fd17633f..f72244a929 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -1723,6 +1723,19 @@ pub const FileIndex = enum(u32) { .index = @intFromEnum(file_index) & ip.getIndexMask(u32), }; } + pub fn toOptional(i: FileIndex) Optional { + return @enumFromInt(@intFromEnum(i)); + } + pub const Optional = enum(u32) { + none = std.math.maxInt(u32), + _, + pub fn unwrap(opt: Optional) ?FileIndex { + return switch (opt) { + .none => null, + _ => @enumFromInt(@intFromEnum(opt)), + }; + } + }; }; const File = struct { |
