From 094c526a0e5264b509f55c0338970e2f9ed29e9f Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sat, 21 Mar 2020 20:16:32 +0100 Subject: [PATCH] Hide some methods from HighlightingAssets --- src/assets.rs | 7 ++++--- src/bin/bat/main.rs | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index 1ce4bb04..954bf615 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -142,11 +142,11 @@ impl HighlightingAssets { self.syntax_set.syntaxes() } - pub fn themes(&self) -> &BTreeMap { - &self.theme_set.themes + pub fn themes(&self) -> impl Iterator { + self.theme_set.themes.keys() } - pub fn get_theme(&self, theme: &str) -> &Theme { + pub(crate) fn get_theme(&self, theme: &str) -> &Theme { match self.theme_set.themes.get(theme) { Some(theme) => theme, None => { @@ -161,6 +161,7 @@ impl HighlightingAssets { } } + #[doc(hidden)] pub fn get_syntax( &self, language: Option<&str>, diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index c71235b0..95654fe6 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -121,7 +121,6 @@ pub fn list_languages(config: &Config) -> Result<()> { pub fn list_themes(cfg: &Config) -> Result<()> { let assets = assets_from_cache_or_binary(); - let themes = assets.themes(); let mut config = cfg.clone(); let mut style = HashSet::new(); style.insert(OutputComponent::Plain); @@ -132,7 +131,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> { let mut stdout = stdout.lock(); if config.colored_output { - for (theme, _) in themes.iter() { + for theme in assets.themes() { writeln!( stdout, "Theme: {}\n", @@ -143,7 +142,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> { writeln!(stdout)?; } } else { - for (theme, _) in themes.iter() { + for theme in assets.themes() { writeln!(stdout, "{}", theme)?; } }