12 lines
238 B
Mojo
12 lines
238 B
Mojo
# probe: a struct that implements write_to prints through print()
|
|
@fieldwise_init
|
|
struct P(Writable):
|
|
var x: Int
|
|
|
|
def write_to(self, mut writer: Some[Writer]):
|
|
writer.write("P(", self.x, ")")
|
|
|
|
|
|
def main():
|
|
print(P(3))
|