aboutsummaryrefslogtreecommitdiff
path: root/src/InternPool.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2025-05-20 03:25:19 +0100
committerGitHub <noreply@github.com>2025-05-20 03:25:19 +0100
commit23c817548bbd3988a5fd224b590a4f6102dbe5db (patch)
tree5448478794cb493b456de356c2e29fb100e81cfb /src/InternPool.zig
parentf2077f57ae03ef21f1bfee6e4e041c5f466fc3be (diff)
parent37a9a4e0f16c1df8de3a4add3a9566b24f024a95 (diff)
downloadzig-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.zig13
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 {