mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-20 01:54:49 +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")
|
|
}
|
|
}
|