@doc """ Returns the map with the keys in kmap renamed to the values in kmap. """ def rename_keys(map, kmap) when is_map(map) and is_map(kmap) do for {key, value} <- map, into: %{}, do: if(new_key = Map.get(kmap, key), do: {new_key, value}, else: {key, value}) end