Documentation ¶
Overview ¶
Package optional contains safer code to handle optional values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
Value is an optional value. The zero value of this structure is equivalent to the one you get when calling None.
func Some ¶
Some constructs a some value unless T is a pointer and points to nil, in which case Some is equivalent to None.
func (Value[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler. An empty value serializes to `null` and otherwise we serialize the underluing value.
func (*Value[T]) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. Note that a `null` JSON value always leads to an empty Value.
Click to show internal directories.
Click to hide internal directories.