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 › Build › Configuration › Wip › addString Public Function addString Doc Source Public Function std.Build.Configuration.Wip.addString
pub fn addString (wip : *Wip , bytes : []const u8 ) Allocator .Error !String Params wip : *Wip bytes : []const u8 File Build/Configuration.zig: 183
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 pub fn addString (wip : *Wip , bytes : []const u8 ) Allocator .Error !String {
const gpa = wip .gpa ;
assert (std .mem .findScalar (u8 , bytes , 0 ) == null );
const gop = try wip .string_table .getOrPutContextAdapted (
gpa ,
@as ([]const u8 , bytes ),
@as (StringTableIndexAdapter , .{ .bytes = wip .string_bytes .items }),
@as (StringTableContext , .{ .bytes = wip .string_bytes .items }),
);
if (gop .found_existing ) return gop .key_ptr .*;
try wip .string_bytes .ensureUnusedCapacity (gpa , bytes .len + 1 );
const new_off : String = @fromBackingInt (@intCast (wip .string_bytes .items .len ));
wip .string_bytes .appendSliceAssumeCapacity (bytes );
wip .string_bytes .appendAssumeCapacity (0 );
gop .key_ptr .* = new_off ;
return new_off ;
}