feature. See also
. The project being documented here (as the example) is the Zig library itself.
Serialize.addOptionalLazyPathEnum
fn addOptionalLazyPathEnum(s: *Serialize, lp: ?std.Build.LazyPath) !Configuration.LazyPath.OptionalIndex
File
Code
fn addOptionalLazyPathEnum(s: *Serialize, lp: ?std.Build.LazyPath) !Configuration.LazyPath.OptionalIndex {
const wc = s.wc;
return @fromBackingInt(@intCast(switch (lp orelse return .none) {
.src_path => |src_path| i: {
const sub_path = try wc.addString(src_path.sub_path);
break :i try wc.addExtraErased(Configuration.LazyPath.SourcePath, .{
.owner = try s.builderToPackage(src_path.owner),
.sub_path = sub_path,
});
},
.generated => |generated| i: {
const sub_path = try wc.addString(generated.sub_path);
break :i try wc.addExtraErased(Configuration.LazyPath.Generated, .{
.flags = .{ .up = @intCast(generated.up) },
.index = generated.index,
.sub_path = sub_path,
});
},
.cwd_relative => |cwd_relative_sub_path| i: {
const sub_path = try wc.addString(cwd_relative_sub_path);
break :i try wc.addExtraErased(Configuration.LazyPath.Relative, .{
.flags = .{ .base = .cwd },
.sub_path = sub_path,
});
},
.relative => |relative| i: {
break :i try wc.addExtraErased(Configuration.LazyPath.Relative, .{
.flags = .{ .base = relative.base },
.sub_path = try wc.addString(relative.sub_path),
});
},
.dependency => |dependency| i: {
const sub_path = try wc.addString(dependency.sub_path);
break :i try wc.addExtraErased(Configuration.LazyPath.SourcePath, .{
.owner = try s.builderToPackage(dependency.dependency.builder),
.sub_path = sub_path,
});
},
}));
}