Hello Method Implementations!
Okay, back to methods! Implementing methods is similar to implementing functions. There are three main differences:
-
You can only implement methods for types you’ve created yourself
-
It must appear inside an
impl
block -
The first parameter must be
self
, or something likeself
Let’s look at an example and explain it. We’ll go back to our old favorite data type, Fruit
: