obj::template.zig (1050B)
1 const std = @import("std"); 2 3 const utils = @import("lib::utils.zig"); 4 5 const Obj = @import("obj.zig").Obj; 6 7 pub fn Template(fields: anytype) type { 8 const Super = Obj(fields); 9 10 return packed struct { 11 const Self = @This(); 12 13 pub const Arg = void; 14 pub const Error = error{OutOfMemory}; 15 16 obj: Super, 17 pub fn init(arg: Arg, allocator: std.mem.Allocator) Error!*Self { 18 _ = arg; 19 _ = allocator; 20 return Error.OutOfMemory; 21 } 22 23 pub fn cast(self: anytype) utils.copy_const(@TypeOf(self), *Super) { 24 return @ptrCast(self); 25 } 26 27 pub fn format(self: *const Self, writer: *std.Io.Writer) !void { 28 _ = self; 29 _ = writer; 30 } 31 32 pub fn eql(self: *const Self, other: *const Self) bool { 33 _ = self; 34 _ = other; 35 return false; 36 } 37 38 pub fn free(self: *const Self, allocator: std.mem.Allocator) void { 39 _ = self; 40 _ = allocator; 41 } 42 }; 43 }