Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Rust

Idiom #140 Delete map entry

Delete from map m the entry having key k.

Explain what happens if k is not an existing key in m.

use std::collections::HashMap;
m.remove(&k);

Returns the value at the key if the key was previously in the map, and 'None' otherwise.
(dissoc m k)

Returns a new map without the key k. If k doesn't exist the original map is returned unaltered.

New implementation...
< >
programming-idioms.org