diff --git a/src/formatter.rs b/src/formatter.rs index b07e7dde6..848625c8b 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -82,6 +82,8 @@ where } } +type Rules = Vec<(Vec, Style)>; + /// Creates `Formatter` instances with preconfigured parameters. #[derive(Clone, Debug)] pub struct FormatterFactory { @@ -91,9 +93,7 @@ pub struct FormatterFactory { #[derive(Clone, Debug)] enum FormatterFactoryKind { PlainText, - Color { - rules: Arc, Style>>, - }, + Color { rules: Arc }, } impl FormatterFactory { @@ -169,14 +169,14 @@ impl Style { pub struct ColorFormatter { output: W, - rules: Arc, Style>>, + rules: Arc, labels: Vec, cached_styles: HashMap, Style>, current_style: Style, } impl ColorFormatter { - pub fn new(output: W, rules: Arc, Style>>) -> ColorFormatter { + pub fn new(output: W, rules: Arc) -> ColorFormatter { ColorFormatter { output, rules, @@ -270,8 +270,8 @@ impl ColorFormatter { } } -fn rules_from_config(config: &config::Config) -> HashMap, Style> { - let mut result = HashMap::new(); +fn rules_from_config(config: &config::Config) -> Rules { + let mut result = vec![]; if let Ok(table) = config.get_table("colors") { for (key, value) in table { let labels = key @@ -286,7 +286,7 @@ fn rules_from_config(config: &config::Config) -> HashMap, Style> { bold: None, underlined: None, }; - result.insert(labels, style); + result.push((labels, style)); } config::ValueKind::Table(style_table) => { let mut style = Style::default(); @@ -310,7 +310,7 @@ fn rules_from_config(config: &config::Config) -> HashMap, Style> { style.underlined = Some(*value); } } - result.insert(labels, style); + result.push((labels, style)); } _ => {} }