mirror of
https://github.com/ziglang/zig.git
synced 2026-02-17 14:59:14 +00:00
std.fmt knows how to format &[N]u8
This commit is contained in:
parent
120e2fdf8b
commit
5fdf3fa195
@ -207,6 +207,13 @@ pub fn formatValue(value: var, context: var, output: fn(@typeOf(context), []cons
|
||||
return false;
|
||||
return output(context, @errorName(value));
|
||||
},
|
||||
builtin.TypeId.Pointer => {
|
||||
if (@typeId(T.child) == builtin.TypeId.Array and T.child.child == u8) {
|
||||
return output(context, (*value)[0..]);
|
||||
} else {
|
||||
@compileError("Unable to format type '" ++ @typeName(T) ++ "'");
|
||||
}
|
||||
},
|
||||
else => if (@canImplicitCast([]const u8, value)) {
|
||||
const casted_value = ([]const u8)(value);
|
||||
return output(context, casted_value);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user