pub fn printAddress(w: *Writer, value: anytype) Error!void w: *WritervalueWriteFailedSee the Writer implementation for detailed diagnostics.
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165pub 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");
}