Fix to_string shadowing fmt::Display fmt (found by clippy)

https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string_shadow_display
This commit is contained in:
ice_iix 2020-06-28 11:33:54 -07:00
parent 287fb3feca
commit 3db08a3fc5
1 changed files with 23 additions and 23 deletions

View File

@ -187,7 +187,29 @@ pub enum Color {
impl fmt::Display for Color {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.to_string())
write!(
f,
"{}",
match *self {
Color::Black => "black".to_owned(),
Color::DarkBlue => "dark_blue".to_owned(),
Color::DarkGreen => "dark_green".to_owned(),
Color::DarkAqua => "dark_aqua".to_owned(),
Color::DarkRed => "dark_red".to_owned(),
Color::DarkPurple => "dark_purple".to_owned(),
Color::Gold => "gold".to_owned(),
Color::Gray => "gray".to_owned(),
Color::DarkGray => "dark_gray".to_owned(),
Color::Blue => "blue".to_owned(),
Color::Green => "green".to_owned(),
Color::Aqua => "aqua".to_owned(),
Color::Red => "red".to_owned(),
Color::LightPurple => "light_purple".to_owned(),
Color::Yellow => "yellow".to_owned(),
Color::White => "white".to_owned(),
Color::RGB(r, g, b) => format!("#{:02X}{:02X}{:02X}", r, g, b),
}
)
}
}
@ -228,28 +250,6 @@ impl Color {
}
}
pub fn to_string(&self) -> String {
match *self {
Color::Black => "black".to_owned(),
Color::DarkBlue => "dark_blue".to_owned(),
Color::DarkGreen => "dark_green".to_owned(),
Color::DarkAqua => "dark_aqua".to_owned(),
Color::DarkRed => "dark_red".to_owned(),
Color::DarkPurple => "dark_purple".to_owned(),
Color::Gold => "gold".to_owned(),
Color::Gray => "gray".to_owned(),
Color::DarkGray => "dark_gray".to_owned(),
Color::Blue => "blue".to_owned(),
Color::Green => "green".to_owned(),
Color::Aqua => "aqua".to_owned(),
Color::Red => "red".to_owned(),
Color::LightPurple => "light_purple".to_owned(),
Color::Yellow => "yellow".to_owned(),
Color::White => "white".to_owned(),
Color::RGB(r, g, b) => format!("#{:02X}{:02X}{:02X}", r, g, b),
}
}
pub fn to_rgb(&self) -> (u8, u8, u8) {
match *self {
Color::Black => (0, 0, 0),