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.
Zig › std/ › Io/ › Writer.zig › printAddress
printAddress
Writer.printAddress
pub fn printAddress (w : *Writer , value : anytype ) Error !void
File
Code
pub fn printAddress (w : *Writer , value : anytype ) Error !void {
const T = @TypeOf (value );
switch (@typeInfo (T )) {
.pointer => |info | {
try w .writeAll (@typeName (info .child ) ++ "@" );
const int = if (info .size == .slice ) @intFromPtr (value .ptr ) else @intFromPtr (value );
return w .printInt (int , 16 , .lower , .{});
},
.optional => |info | {
if (@typeInfo (info .child ) == .pointer ) {
try w .writeAll (@typeName (info .child ) ++ "@" );
try w .printInt (@intFromPtr (value ), 16 , .lower , .{});
return ;
}
},
else => {},
}
@compileError ("cannot format non-pointer type " ++ @typeName (T ) ++ " with * specifier" );
}