You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #6476 - 1c3t3a:1c3t3a-from-over-into, r=llogiq
Added from_over_into lint
Closes#6456
Added a lint that searches for implementations of `Into<..>` and suggests to implement `From<..>` instead, as it comes with a default implementation of `Into`. Category: style.
changelog: added `from_over_into` lint
/// **What it does:** Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead.
13
+
///
14
+
/// **Why is this bad?** According the std docs implementing `From<..>` is preferred since it gives you `Into<..>` for free where the reverse isn't true.
15
+
///
16
+
/// **Known problems:** None.
17
+
///
18
+
/// **Example:**
19
+
///
20
+
/// ```rust
21
+
/// struct StringWrapper(String);
22
+
///
23
+
/// impl Into<StringWrapper> for String {
24
+
/// fn into(self) -> StringWrapper {
25
+
/// StringWrapper(self)
26
+
/// }
27
+
/// }
28
+
/// ```
29
+
/// Use instead:
30
+
/// ```rust
31
+
/// struct StringWrapper(String);
32
+
///
33
+
/// impl From<String> for StringWrapper {
34
+
/// fn from(s: String) -> StringWrapper {
35
+
/// StringWrapper(s)
36
+
/// }
37
+
/// }
38
+
/// ```
39
+
pubFROM_OVER_INTO,
40
+
style,
41
+
"Warns on implementations of `Into<..>` to use `From<..>`"
0 commit comments