pub const Point = packed struct { x: u16 = 0, y: u16 = 0, pub fn add(a: @This(), b: @This()) @This() { return .{ .x = a.x + b.x, .y = a.y + b.y, }; } pub fn max(a: @This(), b: @This()) @This() { return .{ .x = @max(a.x, b.x), .y = @max(a.y, b.y), }; } test "adding" { const testing = @import("std").testing; const a: @This() = .{ .x = 10, .y = 20, }; const b: @This() = .{ .x = 20, .y = 10, }; try testing.expectEqual(@This(){ .x = 30, .y = 30, }, a.add(b)); } test "maximum" { const testing = @import("std").testing; const a: @This() = .{ .x = 10, .y = 20, }; const b: @This() = .{ .x = 20, .y = 10, }; try testing.expectEqual(@This(){ .x = 20, .y = 20, }, a.max(b)); } }; test { _ = Point; }