The impl
, implementation block, allows attaching functions to structures.
I’ve written about structures, here.
The Point
For my example code, I’ll have a simple 2 dimentional Point.
|
|
Adding functionality
Now to add some functions to the Point.
|
|
These add 2 functions that will be appart of the Point structure.
This means all Point structure instances will have
add
andequal
functions.
Using this functionality
|
|