mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-11-29 10:22:05 +02:00
Update receiver.md (#661)
* Update receiver.md Moving the sentence to the third point and requesting an example of `self` vs `mut self`. * Update src/methods/receiver.md Improved the tone of the sentence. Co-authored-by: Martin Geisler <martin@geisler.net> --------- Co-authored-by: Martin Geisler <martin@geisler.net>
This commit is contained in:
parent
47f6a5dacf
commit
cc813973b1
@ -10,9 +10,8 @@ are other possible receivers for a method:
|
||||
* `self`: takes ownership of the object and moves it away from the caller. The
|
||||
method becomes the owner of the object. The object will be dropped (deallocated)
|
||||
when the method returns, unless its ownership is explicitly
|
||||
transmitted.
|
||||
* `mut self`: same as above, but while the method owns the object, it can
|
||||
mutate it too. Complete ownership does not automatically mean mutability.
|
||||
transmitted. Complete ownership does not automatically mean mutability.
|
||||
* `mut self`: same as above, but the method can mutate the object.
|
||||
* No receiver: this becomes a static method on the struct. Typically used to
|
||||
create constructors which are called `new` by convention.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user