Commit 7e7d67d8ee

Meghan <hello@nektro.net>
2021-08-19 13:12:11
std.fmt: add support for printing slices strings (#9562)
1 parent d785dc4
Changed files (1)
lib
lib/std/fmt.zig
@@ -544,6 +544,13 @@ pub fn formatType(
                             return formatText(value, actual_fmt, options, writer);
                         }
                     }
+                    if (comptime std.meta.trait.isZigString(info.child)) {
+                        for (value) |item, i| {
+                            if (i != 0) try formatText(", ", actual_fmt, options, writer);
+                            try formatText(item, actual_fmt, options, writer);
+                        }
+                        return;
+                    }
                     @compileError("Unknown format string: '" ++ actual_fmt ++ "' for type '" ++ @typeName(T) ++ "'");
                 },
                 .Enum, .Union, .Struct => {