Thanks @josevalim for sharing the idea for the below as well. This works better in our Slime partials:
@doc """
Save navigation for structs:
struct_get_in user, [:address, :city]
"""
def struct_get_in(data, key) when is_atom(key) do
struct_get_in(data, [key])
end
def struct_get_in(data, keys) when is_list(keys) do
{first, last} = Enum.split(keys, -1)
first = Enum.map(first, &Access.key(&1, %{}))
last = Enum.map(last, &Access.key(&1, nil))
get_in data, first ++ last
end






















