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 standard library.
std › zig › llvm › Builder › Metadata › String Public Enum String Doc Source Public Enum std.zig.llvm.Builder.Metadata.String
pub const String = enum (u32 ) Structs Types Functions File zig/llvm/Builder.zig: 9127
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182 pub const String = enum (u32 ) {
_ ,
pub const Optional = enum (u32 ) {
none = @bitCast (Metadata .Optional .none ),
_ ,
pub fn wrap (metadata : ?Metadata .String ) Metadata .String .Optional {
return (metadata orelse return .none ).toOptional ();
}
pub fn unwrap (metadata : Metadata .String .Optional ) ?Metadata .String {
return switch (metadata ) {
.none => null ,
else => @fromBackingInt (@backingInt (metadata )),
};
}
pub fn toMetadata (metadata : Metadata .String .Optional ) Metadata .Optional {
return if (metadata .unwrap ()) |m | m .toMetadata ().toOptional () else .none ;
}
};
pub fn toOptional (metadata : Metadata .String ) Metadata .String .Optional {
return @fromBackingInt (@backingInt (metadata ));
}
pub fn toMetadata (metadata : Metadata .String ) Metadata {
return .{ .index = @intCast (@backingInt (metadata )), .kind = .string };
}
pub fn slice (metadata : Metadata .String , builder : *const Builder ) []const u8 {
const index = @backingInt (metadata );
const start = builder .metadata_string_indices .items [index ];
const end = builder .metadata_string_indices .items [index + 1 ];
return builder .metadata_string_bytes .items [start ..end ];
}
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : Adapter , key : []const u8 ) u32 {
return @truncate (std .hash .Wyhash .hash (0 , key ));
}
pub fn eql (ctx : Adapter , lhs_key : []const u8 , _ : void , rhs_index : usize ) bool {
const rhs_metadata : Metadata .String = @fromBackingInt (@intCast (rhs_index ));
return std .mem .eql (u8 , lhs_key , rhs_metadata .slice (ctx .builder ));
}
};
const FormatData = struct {
metadata : Metadata .String ,
builder : *const Builder ,
};
fn format (data : FormatData , w : *Writer ) Writer .Error !void {
try printEscapedString (data .metadata .slice (data .builder ), .always_quote , w );
}
fn fmt (self : Metadata .String , builder : *const Builder ) std .fmt .Alt (FormatData , format ) {
return .{ .data = .{ .metadata = self , .builder = builder } };
}
}