use a bound function for srfFormat
Some checks failed
Generic zig build / build (push) Failing after 36s

This commit is contained in:
Emil Lerch 2026-03-04 16:42:33 -08:00
parent 84b8be4b25
commit 18a4558b47
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -419,7 +419,7 @@ pub const Record = struct {
.@"struct", .@"union" => { .@"struct", .@"union" => {
if (std.meta.hasMethod(field_type, "srfFormat")) { if (std.meta.hasMethod(field_type, "srfFormat")) {
return .{ return .{
.value = field_type.srfFormat(self.allocator, field_name) catch |e| { .value = val.srfFormat(self.allocator, field_name) catch |e| {
log.err( log.err(
"custom format of field {s} failed : {}", "custom format of field {s} failed : {}",
.{ field_name, e }, .{ field_name, e },
@ -1166,7 +1166,8 @@ test "serialize/deserialize" {
if (std.mem.eql(u8, "hi", val)) return .{}; if (std.mem.eql(u8, "hi", val)) return .{};
return error.ValueNotEqualHi; return error.ValueNotEqualHi;
} }
pub fn srfFormat(allocator: std.mem.Allocator, comptime field_name: []const u8) !Value { pub fn srfFormat(self: Self, allocator: std.mem.Allocator, comptime field_name: []const u8) !Value {
_ = self;
_ = field_name; _ = field_name;
return .{ return .{
.string = try allocator.dupe(u8, "hi"), .string = try allocator.dupe(u8, "hi"),