diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 8deef118c01a..010e50e05ef9 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -664,6 +664,10 @@ pub fn formatType( if (max_depth == 0) { return writer.writeAll("{ ... }"); } + if (info.sentinel()) |s| { + const index = std.mem.indexOfSentinel(info.child, s, value[0..]); + return formatBuf(value[0..index], options, writer); + } if (actual_fmt[0] == 's' and info.child == u8) { return formatBuf(&value, options, writer); }