Hi! The difference is that in the case of my_type_instance.f()
the compiler passes the instance either by value or by constant reference depending on what it thinks would be best, but either way you won’t be able to mutate the instance inside the function. In the case of my_type_instance.g()
, you’re telling the compiler to pass the instance by pointer and allow you to mutate the instance behind that pointer.
There’s a 3rd alternative: fn h(self: *const MyType) void {}
which is a kind of combination of the first two because this forces the compiler to pass the instance by pointer, but you won’t be able to mutate that instance.