const std = @import("std"); const expect = std.testing.expect; const MeinTyp = struct { a: f64, b: f64, fn init(self: *MeinTyp) void { self.a = 1.0; self.b = 1.0; } }; fn MyType(comptime T:type) type { return struct { const Self = @This(); a: T, b: T, fn init(this: *Self) void { this.a = 1.0; this.b = 1.0; } }; } test "MeinTyp" { var mt: MeinTyp = undefined; mt.init(); try expect(mt.a == 1.0); try expect(mt.b == 1.0); } test "MyType" { const Myt = MyType(f64); var myInt: Myt = undefined; myInt.init(); try expect(myInt.a == 1.0); try expect(myInt.b == 1.0); myInt.a = 2.0; myInt.b = 3.0; try expect(myInt.a == 2.0); try expect(myInt.b == 3.0); }