const std = @import("std"); pub const ComponentStub = struct { pub fn init(args: ComponentStub) ComponentStub { _ = args; return .{}; } pub fn deinit(self: *ComponentStub) void { _ = self; } }; pub const ComponentType = enum(usize) { component_stub = 0, }; pub const Component = union(ComponentType) { component_stub: ComponentStub, pub fn init(t: ComponentType, args: anytype) Component { switch (t) { ComponentType.component_stub => return Component{ .component_stub = ComponentStub.init(args), }, } } pub fn deinit(self: *Component) void { switch (self.*) { .component_stub => |*comp| comp.deinit(), } } }; test "stub component" { var stub = Component.init(ComponentType.component_stub, .{}); defer stub.deinit(); }