authorgravatar for andrew@raindev.ioAndrew Barchuk <andrew@raindev.io> 2024-11-25 00:09:36+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-11-24 15:09:36-08:00
log1f37b70344d547a6dce2c3357a4ac3a92fa3402f
tree8f6066c1627c60a6504bf5f8a3f89e2218856b53
parentb2030cb9abf73886e1c896ee8d56a3156b6fd3c2
signaturebadge-check Signed by PGP key B5690EEEBB952194

Remove unused `buf` field from `std.fmt.Parser` (#21994)

And make the initialization less error prone by removing a default for iter, which is required for a functional parser std: Add a brief doc comment for `std.fmt.Parser`

1 files changed, 5 insertions(+), 3 deletions(-)

lib/std/fmt.zig+5-3
......@@ -224,7 +224,6 @@ pub const Placeholder = struct {
224224 pub fn parse(comptime str: anytype) Placeholder {
225225 const view = std.unicode.Utf8View.initComptime(&str);
226226 comptime var parser = Parser{
227 .buf = &str,
228227 .iter = view.iterator(),
229228 };
230229
......@@ -311,10 +310,13 @@ pub const Specifier = union(enum) {
311310 named: []const u8,
312311};
313312
313/// A stream based parser for format strings.
314///
315/// Allows to implement formatters compatible with std.fmt without replicating
316/// the standard library behavior.
314317pub const Parser = struct {
315 buf: []const u8,
316318 pos: usize = 0,
317 iter: std.unicode.Utf8Iterator = undefined,
319 iter: std.unicode.Utf8Iterator,
318320
319321 // Returns a decimal number or null if the current character is not a
320322 // digit