Skip to content

Conversation

@sabiwara
Copy link
Contributor

@sabiwara sabiwara commented Apr 5, 2025

It wasn't obvious that we needed to pass a list of fields, I initially tried optional: true.
This makes it more explicit and adds a working example.

I thought it might actually be beneficial to allow some sugar like optional: :all for convenience, WDYT?
Otherwise I find myself doing things like

  @fields [foo: 1, ...]
  @derive {Inspect, optional: Keyword.keys(@fields)}
  defstruct @fields

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: :all is also fine by me!

@sabiwara sabiwara merged commit 068015e into elixir-lang:main Apr 5, 2025
10 checks passed
@sabiwara sabiwara deleted the doc-optional-example branch April 5, 2025 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants