mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
31 lines
503 B
Rust
31 lines
503 B
Rust
#![warn(clippy::to_string_trait_impl)]
|
|
|
|
use std::fmt::{self, Display};
|
|
|
|
struct Point {
|
|
x: usize,
|
|
y: usize,
|
|
}
|
|
|
|
impl ToString for Point {
|
|
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")
|
|
}
|
|
}
|