typed_struct
typed_struct copied to clipboard
Best way to use derive with `typedstruct module: .... do`
This is what I want to write:
@derive Jason.Encoder
typedstruct module: Foo do
field :bar, :string
end
> mix compile
warning: warning: module attribute @derive was set after defstruct, all @derive calls must come before defstruct
To fix it I have to use
require Protocol
Protocol.derive(Jason.Encoder, Foo)