Tiny module to easily get a list of fields for structs.
defmodule MyModule do
defstruct [:foo, :bar]
# Use the module
use StructFields
end
MyModule.fields
#=> [:foo, :bar]
- Add
struct_fields
to your list of dependencies inmix.exs
:
def deps do
[{:struct_fields, "~> 0.1.0"}]
end
- Ensure
struct_fields
is started before your application:
def application do
[applications: [:struct_fields]]
end