Use Display instead of ToString in Rust generators (#18633)

This commit is contained in:
Daniel García
2024-05-12 05:06:03 +02:00
committed by GitHub
parent 365fcd3fb4
commit 970424678e
11 changed files with 51 additions and 51 deletions

View File

@@ -23,12 +23,12 @@ pub enum Color {
}
impl ToString for Color {
fn to_string(&self) -> String {
impl std::fmt::Display for Color {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Red => String::from("RED"),
Self::Green => String::from("GREEN"),
Self::Blue => String::from("BLUE"),
Self::Red => write!(f, "RED"),
Self::Green => write!(f, "GREEN"),
Self::Blue => write!(f, "BLUE"),
}
}
}