Skip to content

phanmn/ex-make_enumerable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MakeEnumerable

Travis Hex.pm Version license

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"]

Installation

If available in Hex, the package can be installed by adding make_enumerable to your list of dependencies in mix.exs:

def deps do
  [
    {:make_enumerable, "~> 0.0.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/make_enumerable.

About

Makes your defstructs enumerable

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%