There already is a generic fallible conversion implementated from &HashMap<_, _> to HeaderMap:
https://docs.rs/http/latest/src/http/header/map.rs.html#2025
Hence, your entire function is superfluous:
use http::HeaderMap;
use std::collections::HashMap;
fn main() {
let mut hash_map = HashMap::new();
hash_map.insert("Content-Type".to_string(), "application/json".to_string());
let header_map: HeaderMap = (&hash_map)
.try_into()
.expect("Hash map should contain valid headers.");
dbg!(header_map);
}