From 3db08a3fc5298780011aaf2d748c788070e862f7 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 28 Jun 2020 11:33:54 -0700 Subject: [PATCH] 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 --- protocol/src/format.rs | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/protocol/src/format.rs b/protocol/src/format.rs index aed2080..55cd4e2 100644 --- a/protocol/src/format.rs +++ b/protocol/src/format.rs @@ -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),