blob: 646ec4db1f11075db378519ee47b6a2741b7eeef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#![warn(clippy::to_string_trait_impl)]
#![feature(min_specialization)]
use std::fmt::{self, Display};
struct Point {
x: usize,
y: usize,
}
impl ToString for Point {
//~^ to_string_trait_impl
fn to_string(&self) -> String {
format!("({}, {})", self.x, self.y)
}
}
struct Foo;
impl Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Foo")
}
}
struct Bar;
impl Bar {
#[allow(clippy::inherent_to_string)]
fn to_string(&self) -> String {
String::from("Bar")
}
}
|