Documentation ¶
Overview ¶
Package optional contains optional type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
Optional represents a type T that may be "null" - that, which value is missing.
func (Optional[T]) Get ¶
Get returns a value, true on non-empty optional and zero-value and false otherwise.
func (Optional[T]) Ptr ¶
func (o Optional[T]) Ptr() *T
Ptr returns a pointer to value or nil pointer. It is safe to change the value inside the pointer (if the T type supports this).
func (Optional[T]) ValueOr ¶
func (o Optional[T]) ValueOr(val T) T
ValueOr returns a value on non-empty optional or provided value otherwise.
func (Optional[T]) ValueOrZero ¶
func (o Optional[T]) ValueOrZero() T
ValueOrZero returns a value on non-empty optional and zero-value otherwise.
Click to show internal directories.
Click to hide internal directories.