2 Checks for methods with certain name prefixes and which
3 doesn't match how self is taken. The actual rules are:
5 |Prefix |Postfix |`self` taken | `self` type |
6 |-------|------------|-------------------------------|--------------|
7 |`as_` | none |`&self` or `&mut self` | any |
8 |`from_`| none | none | any |
9 |`into_`| none |`self` | any |
10 |`is_` | none |`&mut self` or `&self` or none | any |
11 |`to_` | `_mut` |`&mut self` | any |
12 |`to_` | not `_mut` |`self` | `Copy` |
13 |`to_` | not `_mut` |`&self` | not `Copy` |
15 Note: Clippy doesn't trigger methods with `to_` prefix in:
17 Clippy can not tell if a type that implements a trait is `Copy` or not.
18 - Traits implementation, when `&self` is taken.
19 The method signature is controlled by the trait and often `&self` is required for all types that implement the trait
20 (see e.g. the `std::string::ToString` trait).
22 Clippy allows `Pin<&Self>` and `Pin<&mut Self>` if `&self` and `&mut self` is required.
24 Please find more info here:
25 https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv
28 Consistency breeds readability. If you follow the
29 conventions, your users won't be surprised that they, e.g., need to supply a
30 mutable reference to a `as_..` function.
35 fn as_str(self) -> &'static str {