Skip to content

Option: Support omitempty#64

Closed
freeformz wants to merge 1 commit intosamber:masterfrom
freeformz:ffz/OmitEmpty
Closed

Option: Support omitempty#64
freeformz wants to merge 1 commit intosamber:masterfrom
freeformz:ffz/OmitEmpty

Conversation

@freeformz
Copy link
Copy Markdown

This requires changing the underlying type, which may be a breaking change.

AFAICT there isn't any way to do this with the struct based type, but can be done with a slice type (or a map, but maps are heavier weight, so chose slice).

When the slice is empty (len == 0) it is considered absent, when it has an item it is considered present.

This also allows for creating a value via:

Option[T]{value}

Any values appended to the slice after the first are ignored.

This requires changing the underlying type, which *may* be a breaking change.

AFAICT there isn't any way to do this with the struct based type, but can
be done with a slice type (or a map, but maps are heavier weight, so chose slice).

When the slice is empty (len == 0) it is considered absent, when it has an item
it is considered present.

This also allows for creating a value via:

`Option[T]{value}`

Any values appended to the slice after the first are ignored.
@samber
Copy link
Copy Markdown
Owner

samber commented May 25, 2025

resolved in #65

@samber samber closed this May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants