From 4c655f4672572c522fd41296e0fc8737847d1101 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 20 Aug 2026 16:27:49 -0700 Subject: [PATCH] std.Io.Writer.print: update doc comments --- lib/std/Io/Writer.zig | 45 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/std/Io/Writer.zig b/lib/std/Io/Writer.zig index e7c54d9a52549577aafd34c34a27f648e86e490f..2bc12d27c00acd7b605409e02cadf88b09715197 100644 --- a/lib/std/Io/Writer.zig +++ b/lib/std/Io/Writer.zig @@ -584,36 +584,41 @@ pub fn writeAll(w: *Writer, bytes: []const u8) Error!void { /// required, otherwise the digit following ':' is interpreted as **width**. /// /// **specifier** supports: -/// - `x` and `X`: numeric value in hexadecimal notation, or string in hexadecimal bytes -/// - `s`: +/// - "x" and "X": numeric value in hexadecimal notation, or string in hexadecimal bytes +/// - "s": /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination /// - for slices of u8, print the entire slice as a string without zero-termination -/// - `t`: +/// - "t": /// - for enums and tagged unions: prints the tag name /// - for error sets: prints the error name -/// - `b64`: string as standard base64 -/// - `e`: floating point value in scientific notation -/// - `d`: numeric value in decimal notation -/// - `b`: integer value in binary notation -/// - `o`: integer value in octal notation -/// - `c`: integer as an ASCII character. Integer type must have 8 bits at max. -/// - `u`: integer as an UTF-8 sequence. Integer type must have 21 bits at max. -/// - `B`: bytes in SI units (decimal) -/// - `Bi`: bytes in IEC units (binary) -/// - `?`: optional value as either the unwrapped value, or `null`; may be +/// - "b64": string as standard base64 +/// - "e": floating point value in scientific notation +/// - "d": numeric value in decimal notation +/// - "b": integer value in binary notation +/// - "o": integer value in octal notation +/// - "c": integer as an ASCII character. Integer type must have 8 bits at max. +/// - "u": integer as an UTF-8 sequence. Integer type must have 21 bits at max. +/// - "B": bytes in SI units (decimal) +/// - "Bi": bytes in IEC units (binary) +/// - "?": optional value as either the unwrapped value, or `null`; may be /// followed by a format specifier for the underlying value. -/// - `!`: error union value as either the unwrapped value, or the formatted +/// - "!": error union value as either the unwrapped value, or the formatted /// error value; may be followed by a format specifier for the underlying /// value. -/// - `*`: the address of the value instead of the value itself. -/// - `any`: a value of any type using its default format. -/// - `f`: delegates to the `format` method of the type, passing `*Writer` and +/// - "*": the address of the value instead of the value itself. +/// - "any": a value of any type using its default format. +/// - "f": delegates to the `format` method of the type, passing `*Writer` and /// expecting `Error!void` returned. -/// -/// A user type may be a struct, vector, union or enum type. +/// - "q": prints as a double-quote escaped string. Inside the double-quoted +/// string, everything is passed through unmodified, except for the following +/// transformations: +/// - escaped: '\n', '\r', '\t', '\\', '"' +/// - hex-encoded: ASCII control characters +/// - "qf": delegates to the `format` method of the type, while double-quote +/// escaping. /// /// Literal curly braces can be escaped in the format string via doubling, e.g. -/// `{{` or `}}`. +/// "{{" or "}}". pub fn print(w: *Writer, comptime fmt: []const u8, args: anytype) Error!void { const ArgsType = @TypeOf(args); const args_type_info = @typeInfo(ArgsType); -- 2.54.0