| ... | ... | @@ -167,7 +167,8 @@ pub fn format(w: *Writer, comptime fmt: []const u8, args: anytype) Writer.Error! |
| 167 | 167 | comptime assert(fmt[i] == '}'); |
| 168 | 168 | i += 1; |
| 169 | 169 | |
| 170 | | const placeholder = comptime Placeholder.parse(&(fmt[fmt_begin..fmt_end].*)); |
| 170 | const placeholder_array = fmt[fmt_begin..fmt_end].*; |
| 171 | const placeholder = comptime Placeholder.parse(&placeholder_array); |
| 171 | 172 | const arg_pos = comptime switch (placeholder.arg) { |
| 172 | 173 | .none => null, |
| 173 | 174 | .number => |pos| pos, |
| ... | ... | @@ -231,10 +232,6 @@ pub fn deprecatedFormat(writer: anytype, comptime fmt: []const u8, args: anytype |
| 231 | 232 | }; |
| 232 | 233 | } |
| 233 | 234 | |
| 234 | | fn cacheString(str: anytype) []const u8 { |
| 235 | | return &str; |
| 236 | | } |
| 237 | | |
| 238 | 235 | pub const Placeholder = struct { |
| 239 | 236 | specifier_arg: []const u8, |
| 240 | 237 | fill: u8, |
| ... | ... | @@ -243,7 +240,7 @@ pub const Placeholder = struct { |
| 243 | 240 | width: Specifier, |
| 244 | 241 | precision: Specifier, |
| 245 | 242 | |
| 246 | | pub fn parse(bytes: []const u8) Placeholder { |
| 243 | pub fn parse(comptime bytes: []const u8) Placeholder { |
| 247 | 244 | var parser: Parser = .{ .bytes = bytes, .i = 0 }; |
| 248 | 245 | const arg = parser.specifier() catch |err| @compileError(@errorName(err)); |
| 249 | 246 | const specifier_arg = parser.until(':'); |
| ... | ... | @@ -298,8 +295,10 @@ pub const Placeholder = struct { |
| 298 | 295 | |
| 299 | 296 | if (parser.char()) |b| @compileError("extraneous trailing character '" ++ &[1]u8{b} ++ "'"); |
| 300 | 297 | |
| 298 | const specifier_array = specifier_arg[0..specifier_arg.len].*; |
| 299 | |
| 301 | 300 | return .{ |
| 302 | | .specifier_arg = cacheString(specifier_arg[0..specifier_arg.len].*), |
| 301 | .specifier_arg = &specifier_array, |
| 303 | 302 | .fill = fill orelse default_fill_char, |
| 304 | 303 | .alignment = alignment orelse default_alignment, |
| 305 | 304 | .arg = arg, |