Closed
Description
Lint name: wrong_self_convention
I tried this code:
trait F32Ext {
fn to_something_else(self) -> f32;
}
I get this:
warning: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
--> src/main.rs:66:21
|
66 | fn to_some_unit(self) -> f32;
| ^^^^
|
If this trait is implemented for types such as f32
, then i think the to_
prefix makes complete sense - f32
already has methods with that prefix and it makes no sense to take such a small type by reference.
I think this lint should allow to_
on Copy types to take self
without reference.
Meta
cargo clippy -V
: clippy 0.1.52 (e9920ef 2021-02-11)
rustc -Vv
:
rustc 1.52.0-nightly (e9920ef77 2021-02-11)
binary: rustc
commit-hash: e9920ef7749d11fc71cc32ca4ba055bcfeaab945
commit-date: 2021-02-11
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1