Closed
Description
What it does
Having a function with &mut self
as an argument, and actually never use self
as mutable inside it wont give us any compiler or clippy warning...
here is an example
fn method(&mut self) -> String {
self.a_str.to_string()
}
I think in this case clippy should say self doesn't need to be mutable
.
Lint Name
unused_mutable_self
Category
correctness
Advantage
- self wont be borrowed anymore in this function when its dont needed
Drawbacks
No response
Example
fn method(&mut self) -> String {
self.a_str.to_string()
}
Could be written as:
fn method(&self) -> String {
self.a_str.to_string()
}