pub fn resolve_in_map<'a, V>(
map: &'a HashMap<String, V>,
name: &str,
extensions: &[&str],
) -> Option<&'a V>Expand description
Looks up a key in a HashMap with extension-agnostic fallback.
Tries the exact name first. If not found and the name has a recognized
extension, strips the extension and tries the base name. This enables
lookups like "config.j2" to find entries registered as "config".
ยงExample
use std::collections::HashMap;
use standout_render::file_loader::resolve_in_map;
let mut map = HashMap::new();
map.insert("config".to_string(), "content");
map.insert("config.yaml".to_string(), "yaml content");
let extensions = &[".yaml", ".yml", ".j2"];
// Exact match
assert_eq!(resolve_in_map(&map, "config", extensions), Some(&"content"));
assert_eq!(resolve_in_map(&map, "config.yaml", extensions), Some(&"yaml content"));
// Extension-agnostic fallback: .j2 is stripped, finds "config"
assert_eq!(resolve_in_map(&map, "config.j2", extensions), Some(&"content"));
// No match
assert_eq!(resolve_in_map(&map, "missing", extensions), None::<&&str>);