Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

addOptionalLazyPathEnum

Serialize.addOptionalLazyPathEnum
fn addOptionalLazyPathEnum(s: *Serialize, lp: ?std.Build.LazyPath) !Configuration.LazyPath.OptionalIndex

File

lib/std/Build/Serialize.zig:735

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,
            });
        },
    }));
}