25 lines
492 B
Plaintext
25 lines
492 B
Plaintext
#import "modules/std.sx";
|
|
|
|
Point :: struct { x: s32; y: s32; }
|
|
|
|
Eq :: protocol {
|
|
eq :: (other: Self) -> bool;
|
|
}
|
|
|
|
impl Eq for Point {
|
|
eq :: (self: *Point, other: Point) -> bool {
|
|
self.x == other.x and self.y == other.y;
|
|
}
|
|
}
|
|
|
|
are_equal :: ($T: Type/Eq, a: T, b: T) -> bool {
|
|
a.eq(b);
|
|
}
|
|
|
|
main :: () {
|
|
p1 := Point.{ x = 1, y = 2 };
|
|
p2 := Point.{ x = 1, y = 2 };
|
|
p3 := Point.{ x = 3, y = 4 };
|
|
print("P6.1: {} {}\n", are_equal(p1, p2), are_equal(p1, p3));
|
|
}
|