try_insert

Function try_insert 

Source
pub fn try_insert<M, K, V>(map: &mut M, key: &K, value: V) -> Result<()>
where M: Insert<K, V>, K: Eq + Hash + Clone + Debug,
Expand description

Insert a key-value pair into a map implementing the Insert trait if the key does not already exist.

If the key already exists, this returns an error with a message indicating the key’s existence.