mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 18:51:44 +03:00
std.Io.Writer: placeholder code for new {q} format character
intendend to print something with double quotes, escaped the same as a zig string literal.
This commit is contained in:
@@ -1170,6 +1170,25 @@ pub fn printValue(
|
||||
},
|
||||
else => invalidFmtError(fmt, value),
|
||||
},
|
||||
// TODO make this print double quotes and quote-escape the string
|
||||
// according to zig string syntax rules
|
||||
'q' => switch (@typeInfo(T)) {
|
||||
.pointer => |info| switch (info.size) {
|
||||
.one, .slice => {
|
||||
const slice: []const u8 = value;
|
||||
return w.alignBufferOptions(slice, options);
|
||||
},
|
||||
.many, .c => {
|
||||
const slice: [:0]const u8 = std.mem.span(value);
|
||||
return w.alignBufferOptions(slice, options);
|
||||
},
|
||||
},
|
||||
.array => {
|
||||
const slice: []const u8 = &value;
|
||||
return w.alignBufferOptions(slice, options);
|
||||
},
|
||||
else => invalidFmtError(fmt, value),
|
||||
},
|
||||
'B' => switch (@typeInfo(T)) {
|
||||
.int, .comptime_int => return w.printByteSize(value, .decimal, options),
|
||||
.@"struct" => return value.formatByteSize(w, .decimal),
|
||||
|
||||
Reference in New Issue
Block a user