Documentation
¶
Index ¶
- type Optional
- func (self Optional[T]) And(opt Optional[T]) Optional[T]
- func (self Optional[T]) AndThen(f func(T) Optional[T]) Optional[T]
- func (self Optional[T]) Filter(fn func(T) bool) Optional[T]
- func (self Optional[T]) IfPresent(consume func(T))
- func (self Optional[T]) IsNone() bool
- func (self Optional[T]) IsSome() bool
- func (self Optional[T]) IsSomeAnd(predicate func(T) bool) bool
- func (self Optional[T]) Map(f func(T) T) Optional[T]
- func (self Optional[T]) MapOr(defaultValue T, f func(T) T) T
- func (self Optional[T]) MapOrElse(df func() T, f func(T) T) T
- func (self Optional[T]) Or(opt Optional[T]) Optional[T]
- func (self Optional[T]) OrElse(f func() Optional[T]) Optional[T]
- func (self Optional[T]) String() string
- func (self Optional[T]) Value() T
- func (self Optional[T]) ValueOr(defaultValue T) T
- func (self Optional[T]) ValueOrElse(defaultFunc func() T) T
- func (self Optional[T]) ValueOrZero() T
- func (self Optional[T]) Xor(opt Optional[T]) Optional[T]
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 is a value that may or may not be present.
func (Optional[T]) AndThen ¶ added in v0.2.0
AndThen returns None if the option is None, otherwise calls f with the wrapped value and returns the result.
func (Optional[T]) IsSomeAnd ¶ added in v0.2.0
IsSomeAnd returns true if the Optional is Some and satisfies the given predicate.
func (Optional[T]) Map ¶
Map returns None if the option is None, otherwise calls the given function and returns the result.
func (Optional[T]) MapOr ¶ added in v0.2.0
func (self Optional[T]) MapOr(defaultValue T, f func(T) T) T
MapOr returns None if the option is None, otherwise calls the given function and returns the result.
func (Optional[T]) MapOrElse ¶ added in v0.2.0
func (self Optional[T]) MapOrElse(df func() T, f func(T) T) T
MapOrElse returns None if the option is None, otherwise calls the given function and returns the result.
func (Optional[T]) Or ¶
Or returns the given opt if the option is None, otherwise returns the option.
func (Optional[T]) OrElse ¶
OrElse returns the Optional if it contains a value, otherwise calls f and returns the result.
func (Optional[T]) Value ¶
func (self Optional[T]) Value() T
Value returns the value of the Optional.
func (Optional[T]) ValueOr ¶ added in v0.2.0
func (self Optional[T]) ValueOr(defaultValue T) T
ValueOr returns the Optional if it is Some, otherwise returns the given default value.
func (Optional[T]) ValueOrElse ¶ added in v0.2.0
func (self Optional[T]) ValueOrElse(defaultFunc func() T) T
ValueOrElse returns the Optional if it is Some, otherwise returns the given default value.
func (Optional[T]) ValueOrZero ¶ added in v0.2.0
func (self Optional[T]) ValueOrZero() T
ValueOrZero returns the Optional if it is Some, otherwise returns the zero value of the type.