| ... | @@ -224,7 +224,6 @@ pub const Placeholder = struct { | ... | @@ -224,7 +224,6 @@ pub const Placeholder = struct { |
| 224 | pub fn parse(comptime str: anytype) Placeholder { | 224 | pub fn parse(comptime str: anytype) Placeholder { |
| 225 | const view = std.unicode.Utf8View.initComptime(&str); | 225 | const view = std.unicode.Utf8View.initComptime(&str); |
| 226 | comptime var parser = Parser{ | 226 | comptime var parser = Parser{ |
| 227 | .buf = &str, | | |
| 228 | .iter = view.iterator(), | 227 | .iter = view.iterator(), |
| 229 | }; | 228 | }; |
| 230 | | 229 | |
| ... | @@ -311,10 +310,13 @@ pub const Specifier = union(enum) { | ... | @@ -311,10 +310,13 @@ pub const Specifier = union(enum) { |
| 311 | named: []const u8, | 310 | named: []const u8, |
| 312 | }; | 311 | }; |
| 313 | | 312 | |
| | 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. |
| 314 | pub const Parser = struct { | 317 | pub const Parser = struct { |
| 315 | buf: []const u8, | | |
| 316 | pos: usize = 0, | 318 | pos: usize = 0, |
| 317 | iter: std.unicode.Utf8Iterator = undefined, | 319 | iter: std.unicode.Utf8Iterator, |
| 318 | | 320 | |
| 319 | // Returns a decimal number or null if the current character is not a | 321 | // Returns a decimal number or null if the current character is not a |
| 320 | // digit | 322 | // digit |