You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-25 10:12:53 +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:
committed by
GitHub
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
|
* `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)
|
method becomes the owner of the object. The object will be dropped (deallocated)
|
||||||
when the method returns, unless its ownership is explicitly
|
when the method returns, unless its ownership is explicitly
|
||||||
transmitted.
|
transmitted. Complete ownership does not automatically mean mutability.
|
||||||
* `mut self`: same as above, but while the method owns the object, it can
|
* `mut self`: same as above, but the method can mutate the object.
|
||||||
mutate it too. Complete ownership does not automatically mean mutability.
|
|
||||||
* No receiver: this becomes a static method on the struct. Typically used to
|
* No receiver: this becomes a static method on the struct. Typically used to
|
||||||
create constructors which are called `new` by convention.
|
create constructors which are called `new` by convention.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user