Shorten the Inspect form of RDF.PrefixMap

This commit is contained in:
Marcel Otto 2020-10-15 09:05:43 +02:00
parent 36ab48c0e7
commit 217139deae

View file

@ -395,4 +395,20 @@ defmodule RDF.PrefixMap do
def count(%RDF.PrefixMap{map: map}), do: Enumerable.count(map)
def slice(_prefix_map), do: {:error, __MODULE__}
end
defimpl Inspect do
import Inspect.Algebra
def inspect(prefix_map, opts) do
map = Map.to_list(prefix_map.map)
open = color("%RDF.PrefixMap{", :map, opts)
sep = color(",", :map, opts)
close = color("}", :map, opts)
container_doc(open, map, close, opts, &Inspect.List.keyword/2,
separator: sep,
break: :strict
)
end
end
end