authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-09 19:42:31-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-09 19:42:31-04:00
log5fdf3fa1954f8f8f2a4558723078c0b1400b8574
tree57a8b95e37cb64fef1d62145ed34a0f7f6ff24e8
parent120e2fdf8b6ec01aef3f06eca3b594c0d6b3b42c

std.fmt knows how to format &[N]u8


1 files changed, 7 insertions(+), 0 deletions(-)

std/fmt/index.zig+7
......@@ -207,6 +207,13 @@ pub fn formatValue(value: var, context: var, output: fn(@typeOf(context), []cons
207207 return false;
208208 return output(context, @errorName(value));
209209 },
210 builtin.TypeId.Pointer => {
211 if (@typeId(T.child) == builtin.TypeId.Array and T.child.child == u8) {
212 return output(context, (*value)[0..]);
213 } else {
214 @compileError("Unable to format type '" ++ @typeName(T) ++ "'");
215 }
216 },
210217 else => if (@canImplicitCast([]const u8, value)) {
211218 const casted_value = ([]const u8)(value);
212219 return output(context, casted_value);