make_enumerable v0.0.1 MakeEnumerable
Makes your structures enumerable!
The MakeEnumerable
module injects defimpl Enumerable
for your structs,
as structs are basically maps
with special tag (member) __struct__
.
The module hides the tag __struct__
and delegates all other members
to map to be Enumerable
.
defmodule Bar do
use MakeEnumerable
defstruct foo: "a", baz: 10
end
iex> import Bar
iex> Enum.map(%Bar{}, fn({k, v}) -> {k, v} end)
[baz: 10, foo: "a"]