Login
Remember
Register
Ask a Question
Explain the rule of using &self, self and &mut self in the declaration method?
0
votes
asked
Dec 28, 2023
in
Rust
by
Robin
Explain the rule of using &self, self and &mut self in the declaration method?
rust-declarationmethod
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Dec 28, 2023
by
Robin
&self : when Read-only reference is required to the function.
self : When a value is to be consumed by the function.
&mut : When a value needs to be mutated by the function with consuming it.
...