Skip to content

Commit 1f37b70

Browse files
authored
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 parent b2030cb commit 1f37b70

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/std/fmt.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
314317
pub 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

0 commit comments

Comments
 (0)