diff options
author | Alex Novak <alex@alexnovak.dev> | 2020-06-01 11:35:56 -0400 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-06-03 19:44:41 +0200 |
commit | 9e2ea5fdd43d90b4c8cecd8e1f0354fabdbe344c (patch) | |
tree | de7cdce00a144a09b58c025d73f5600de9052ee8 /src | |
parent | 48b4a6a9064b86d099fb8ff38f40aae45bbe9a32 (diff) |
Incorporating feedback
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/bat/main.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index c9950ae1..818b64d2 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -63,15 +63,15 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> { } fn get_syntax_mapping_to_paths( - mappings: Vec<(GlobMatcher, MappingTarget)>, + mappings: &[(GlobMatcher, MappingTarget)], ) -> HashMap<String, Vec<String>> { - let mut map = HashMap::new(); + let mut map: HashMap<String, Vec<String>> = HashMap::new(); for mapping in mappings { - match mapping.1 { - MappingTarget::MapToUnknown => {} - MappingTarget::MapTo(s) => { - let globs = map.entry(s.into()).or_insert(Vec::new()); - globs.push(mapping.0.glob().glob().into()); + match mapping { + (_, MappingTarget::MapToUnknown) => {} + (matcher, MappingTarget::MapTo(s)) => { + let globs = map.entry((*s).into()).or_insert(Vec::new()); + globs.push(matcher.glob().glob().into()); } } } @@ -88,14 +88,15 @@ pub fn list_languages(config: &Config) -> Result<()> { .collect::<Vec<_>>(); languages.sort_by_key(|lang| lang.name.to_uppercase()); - let configured_languages = - get_syntax_mapping_to_paths(config.syntax_mapping.mappings().clone()); + let configured_languages = get_syntax_mapping_to_paths(config.syntax_mapping.mappings()); for lang in languages.iter_mut() { - if configured_languages.contains_key(&lang.name) { - let additional_paths = configured_languages.get(&lang.name).unwrap(); - lang.file_extensions - .extend(additional_paths.iter().cloned()); + match configured_languages.get(&lang.name) { + Some(additional_paths) => { + lang.file_extensions + .extend(additional_paths.iter().cloned()); + } + None => {} } } |