Documentation ¶
Index ¶
- Variables
- type Optional
- func FlatMap[T any, V any](optional Optional[T], fn func(T) Optional[V]) Optional[V]
- func From[T any](value T) Optional[T]
- func FromError[T any](value T, err error) Optional[T]
- func FromNillable[T any](value interface{}) Optional[T]
- func None[T any]() Optional[T]
- func Some[T any](value T) Optional[T]
- func (optional Optional[T]) FlatMap(fn func(T) Optional[any]) Optional[any]
- func (optional Optional[T]) Get() T
- func (optional Optional[T]) GetDefault(value T) T
- func (optional Optional[T]) GetElse(fn func() T) T
- func (optional Optional[T]) GetPtr() *T
- func (optional Optional[T]) GetTry() (value T, err error)
- func (optional Optional[T]) IfPresent(fn func(T))
- func (optional Optional[T]) IfPresentElse(fn func(T), fn_ func())
- func (optional Optional[T]) IsEmpty() bool
- func (optional Optional[T]) IsPresent() bool
- func (optional Optional[T]) Map(fn func(T) T)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrorEmpty = errors.New("optional has no value")
)
Functions ¶
This section is empty.
Types ¶
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
func FromNillable ¶
func (Optional[T]) GetDefault ¶
func (optional Optional[T]) GetDefault(value T) T
func (Optional[T]) IfPresentElse ¶
func (optional Optional[T]) IfPresentElse(fn func(T), fn_ func())
Click to show internal directories.
Click to hide internal directories.