| ... | @@ -584,36 +584,41 @@ pub fn writeAll(w: *Writer, bytes: []const u8) Error!void { | ... | @@ -584,36 +584,41 @@ pub fn writeAll(w: *Writer, bytes: []const u8) Error!void { |
| 584 | /// required, otherwise the digit following ':' is interpreted as **width**. | 584 | /// required, otherwise the digit following ':' is interpreted as **width**. |
| 585 | /// | 585 | /// |
| 586 | /// **specifier** supports: | 586 | /// **specifier** supports: |
| 587 | /// - `x` and `X`: numeric value in hexadecimal notation, or string in hexadecimal bytes | 587 | /// - "x" and "X": numeric value in hexadecimal notation, or string in hexadecimal bytes |
| 588 | /// - `s`: | 588 | /// - "s": |
| 589 | /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination | 589 | /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination |
| 590 | /// - for slices of u8, print the entire slice as a string without zero-termination | 590 | /// - for slices of u8, print the entire slice as a string without zero-termination |
| 591 | /// - `t`: | 591 | /// - "t": |
| 592 | /// - for enums and tagged unions: prints the tag name | 592 | /// - for enums and tagged unions: prints the tag name |
| 593 | /// - for error sets: prints the error name | 593 | /// - for error sets: prints the error name |
| 594 | /// - `b64`: string as standard base64 | 594 | /// - "b64": string as standard base64 |
| 595 | /// - `e`: floating point value in scientific notation | 595 | /// - "e": floating point value in scientific notation |
| 596 | /// - `d`: numeric value in decimal notation | 596 | /// - "d": numeric value in decimal notation |
| 597 | /// - `b`: integer value in binary notation | 597 | /// - "b": integer value in binary notation |
| 598 | /// - `o`: integer value in octal notation | 598 | /// - "o": integer value in octal notation |
| 599 | /// - `c`: integer as an ASCII character. Integer type must have 8 bits at max. | 599 | /// - "c": integer as an ASCII character. Integer type must have 8 bits at max. |
| 600 | /// - `u`: integer as an UTF-8 sequence. Integer type must have 21 bits at max. | 600 | /// - "u": integer as an UTF-8 sequence. Integer type must have 21 bits at max. |
| 601 | /// - `B`: bytes in SI units (decimal) | 601 | /// - "B": bytes in SI units (decimal) |
| 602 | /// - `Bi`: bytes in IEC units (binary) | 602 | /// - "Bi": bytes in IEC units (binary) |
| 603 | /// - `?`: optional value as either the unwrapped value, or `null`; may be | 603 | /// - "?": optional value as either the unwrapped value, or `null`; may be |
| 604 | /// followed by a format specifier for the underlying value. | 604 | /// followed by a format specifier for the underlying value. |
| 605 | /// - `!`: error union value as either the unwrapped value, or the formatted | 605 | /// - "!": error union value as either the unwrapped value, or the formatted |
| 606 | /// error value; may be followed by a format specifier for the underlying | 606 | /// error value; may be followed by a format specifier for the underlying |
| 607 | /// value. | 607 | /// value. |
| 608 | /// - `*`: the address of the value instead of the value itself. | 608 | /// - "*": the address of the value instead of the value itself. |
| 609 | /// - `any`: a value of any type using its default format. | 609 | /// - "any": a value of any type using its default format. |
| 610 | /// - `f`: delegates to the `format` method of the type, passing `*Writer` and | 610 | /// - "f": delegates to the `format` method of the type, passing `*Writer` and |
| 611 | /// expecting `Error!void` returned. | 611 | /// expecting `Error!void` returned. |
| 612 | /// | 612 | /// - "q": prints as a double-quote escaped string. Inside the double-quoted |
| 613 | /// A user type may be a struct, vector, union or enum type. | 613 | /// string, everything is passed through unmodified, except for the following |
| | 614 | /// transformations: |
| | 615 | /// - escaped: '\n', '\r', '\t', '\\', '"' |
| | 616 | /// - hex-encoded: ASCII control characters |
| | 617 | /// - "qf": delegates to the `format` method of the type, while double-quote |
| | 618 | /// escaping. |
| 614 | /// | 619 | /// |
| 615 | /// Literal curly braces can be escaped in the format string via doubling, e.g. | 620 | /// Literal curly braces can be escaped in the format string via doubling, e.g. |
| 616 | /// `{{` or `}}`. | 621 | /// "{{" or "}}". |
| 617 | pub fn print(w: *Writer, comptime fmt: []const u8, args: anytype) Error!void { | 622 | pub fn print(w: *Writer, comptime fmt: []const u8, args: anytype) Error!void { |
| 618 | const ArgsType = @TypeOf(args); | 623 | const ArgsType = @TypeOf(args); |
| 619 | const args_type_info = @typeInfo(ArgsType); | 624 | const args_type_info = @typeInfo(ArgsType); |