Function printAddress [src]

Prototype

pub fn printAddress(w: *Writer, value: anytype) Error!void

Parameters

w: *Writer

Possible Errors

WriteFailed

See the Writer implementation for detailed diagnostics.

Source

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