| ... | @@ -385,23 +385,23 @@ pub fn serializeCpuAlloc(ally: Allocator, cpu: std.Target.Cpu) Allocator.Error![ | ... | @@ -385,23 +385,23 @@ pub fn serializeCpuAlloc(ally: Allocator, cpu: std.Target.Cpu) Allocator.Error![ |
| 385 | /// Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed. | 385 | /// Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed. |
| 386 | /// | 386 | /// |
| 387 | /// See also `fmtIdFlags`. | 387 | /// See also `fmtIdFlags`. |
| 388 | pub fn fmtId(bytes: []const u8) std.fmt.Formatter(FormatId, FormatId.render) { | 388 | pub fn fmtId(bytes: []const u8) FormatId { |
| 389 | return .{ .data = .{ .bytes = bytes, .flags = .{} } }; | 389 | return .{ .bytes = bytes, .flags = .{} }; |
| 390 | } | 390 | } |
| 391 | | 391 | |
| 392 | /// Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed. | 392 | /// Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed. |
| 393 | /// | 393 | /// |
| 394 | /// See also `fmtId`. | 394 | /// See also `fmtId`. |
| 395 | pub fn fmtIdFlags(bytes: []const u8, flags: FormatId.Flags) std.fmt.Formatter(FormatId, FormatId.render) { | 395 | pub fn fmtIdFlags(bytes: []const u8, flags: FormatId.Flags) FormatId { |
| 396 | return .{ .data = .{ .bytes = bytes, .flags = flags } }; | 396 | return .{ .bytes = bytes, .flags = flags }; |
| 397 | } | 397 | } |
| 398 | | 398 | |
| 399 | pub fn fmtIdPU(bytes: []const u8) std.fmt.Formatter(FormatId, FormatId.render) { | 399 | pub fn fmtIdPU(bytes: []const u8) FormatId { |
| 400 | return .{ .data = .{ .bytes = bytes, .flags = .{ .allow_primitive = true, .allow_underscore = true } } }; | 400 | return .{ .bytes = bytes, .flags = .{ .allow_primitive = true, .allow_underscore = true } }; |
| 401 | } | 401 | } |
| 402 | | 402 | |
| 403 | pub fn fmtIdP(bytes: []const u8) std.fmt.Formatter(FormatId, FormatId.render) { | 403 | pub fn fmtIdP(bytes: []const u8) FormatId { |
| 404 | return .{ .data = .{ .bytes = bytes, .flags = .{ .allow_primitive = true } } }; | 404 | return .{ .bytes = bytes, .flags = .{ .allow_primitive = true } }; |
| 405 | } | 405 | } |
| 406 | | 406 | |
| 407 | test fmtId { | 407 | test fmtId { |
| ... | @@ -447,7 +447,7 @@ pub const FormatId = struct { | ... | @@ -447,7 +447,7 @@ pub const FormatId = struct { |
| 447 | }; | 447 | }; |
| 448 | | 448 | |
| 449 | /// Print the string as a Zig identifier, escaping it with `@""` syntax if needed. | 449 | /// Print the string as a Zig identifier, escaping it with `@""` syntax if needed. |
| 450 | fn render(ctx: FormatId, writer: *Writer) Writer.Error!void { | 450 | pub fn format(ctx: FormatId, writer: *Writer) Writer.Error!void { |
| 451 | const bytes = ctx.bytes; | 451 | const bytes = ctx.bytes; |
| 452 | if (isValidId(bytes) and | 452 | if (isValidId(bytes) and |
| 453 | (ctx.flags.allow_primitive or !std.zig.isPrimitive(bytes)) and | 453 | (ctx.flags.allow_primitive or !std.zig.isPrimitive(bytes)) and |