aboutsummaryrefslogtreecommitdiff
path: root/std/io.zig
diff options
context:
space:
mode:
authortgschultz <tgschultz@gmail.com>2018-12-09 20:52:16 -0600
committertgschultz <tgschultz@gmail.com>2018-12-09 20:52:16 -0600
commit1188da926ff4cddd5818d85d45b087f6207dfef9 (patch)
tree839e4ef303dd468f29ae7dda5a386cd46b0c971d /std/io.zig
parent8423bd423b7a8cf32246f9d27a400a2cf14ce770 (diff)
downloadzig-1188da926ff4cddd5818d85d45b087f6207dfef9.tar.gz
zig-1188da926ff4cddd5818d85d45b087f6207dfef9.zip
Minor change to custom (de)serializer to allow them to be defined outside of the struct and aliased inside it. This will enable alternate generic serializers (i.e. one that follows pointers) on a struct-by-struct basis.
Diffstat (limited to 'std/io.zig')
-rw-r--r--std/io.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/std/io.zig b/std/io.zig
index 5f710a5033..c397ff6ede 100644
--- a/std/io.zig
+++ b/std/io.zig
@@ -1146,7 +1146,7 @@ pub fn Deserializer(endian: builtin.Endian, is_packed: bool, comptime Error: typ
const child_type_id = @typeId(C);
//custom deserializer: fn(self: *Self, deserializer: var) !void
- if (comptime trait.hasFn("deserialize")(C)) return ptr.deserialize(self);
+ if (comptime trait.hasFn("deserialize")(C)) return C.deserialize(ptr, self);
if (comptime trait.isPacked(C) and !is_packed) {
var packed_deserializer = Deserializer(endian, true, Error).init(self.in_stream);
@@ -1308,8 +1308,8 @@ pub fn Serializer(endian: builtin.Endian, is_packed: bool, comptime Error: type)
return;
}
- //custom serializer: fn(self: *const Self, serializer: var) !void
- if (comptime trait.hasFn("serialize")(T)) return value.serialize(self);
+ //custom serializer: fn(self: Self, serializer: var) !void
+ if (comptime trait.hasFn("serialize")(T)) return T.serialize(value, self);
if (comptime trait.isPacked(T) and !is_packed) {
var packed_serializer = Serializer(endian, true, Error).init(self.out_stream);