diff --git a/src/colors.rs b/src/colors.rs index 00e826a1c..bfad8fb16 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -1,7 +1,8 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; +use std::iter::FromIterator; -pub fn color_groups() -> HashMap> { - [ +pub fn color_groups() -> BTreeMap<&'static str, Vec<(&'static str, &'static str)>> { + BTreeMap::from_iter([ ( "Blue", vec![ @@ -198,16 +199,5 @@ pub fn color_groups() -> HashMap> { ("darkkhaki", "#bdb76b"), ], ), - ] - .iter() - .map(|(name, colors)| { - ( - name.to_string(), - colors - .iter() - .map(|(color, hex)| (color.to_string(), hex.to_string())) - .collect(), - ) - }) - .collect() + ]) } diff --git a/src/subcommands/show_colors.rs b/src/subcommands/show_colors.rs index 7aaa716ce..71868989b 100644 --- a/src/subcommands/show_colors.rs +++ b/src/subcommands/show_colors.rs @@ -12,8 +12,6 @@ use crate::utils::bat::output::{OutputType, PagingMode}; #[cfg(not(tarpaulin_include))] pub fn show_colors() -> std::io::Result<()> { - use itertools::Itertools; - use crate::{delta::DiffType, utils}; let assets = utils::bat::assets::load_highlighting_assets(); @@ -38,7 +36,7 @@ pub fn show_colors() -> std::io::Result<()> { is_syntax_highlighted: true, ..style::Style::default() }; - for (group, color_names) in colors::color_groups().iter().sorted() { + for (group, color_names) in colors::color_groups() { writeln!(painter.writer, "\n\n{}\n", title_style.paint(group))?; for (color_name, hex) in color_names { // Two syntax-highlighted lines without background color