pub fn try_insert<K, V>(
map: &mut HashMap<K, V>,
key: &K,
value: V,
) -> Result<()>Expand description
Inserts a key-value pair into a HashMap if the key does not already exist.
If the key already exists, it returns an error with a message indicating the key’s existence.