formatter: make `color_for_name()` a free function
The function doesn't use its `&self` argument anyway.
@@ -208,14 +208,15 @@ impl<W> ColorFormatter<W> {
}
}
- let color = self.color_for_name(best_match.1);
+ let color = color_for_name(best_match.1);
self.cached_colors
.insert(self.labels.clone(), color.clone());
color
}
}
+}
- fn color_for_name(&self, color_name: &str) -> Vec<u8> {
+fn color_for_name(color_name: &str) -> Vec<u8> {
match color_name {
"black" => b"\x1b[30m".to_vec(),
"red" => b"\x1b[31m".to_vec(),
@@ -236,7 +237,6 @@ impl<W> ColorFormatter<W> {
_ => b"\x1b[0m".to_vec(),
}
}
-}
impl<W: Write> Write for ColorFormatter<W> {
fn write(&mut self, data: &[u8]) -> Result<usize, Error> {
