Documentation ¶
Index ¶
- type Four
- func (s *Four[TT, UU, VV, WW]) SetT(t TT)
- func (s *Four[TT, UU, VV, WW]) SetU(u UU)
- func (s *Four[TT, UU, VV, WW]) SetV(v VV)
- func (s *Four[TT, UU, VV, WW]) SetW(w WW)
- func (s Four[TT, UU, VV, WW]) String() string
- func (s Four[TT, UU, VV, WW]) T() TT
- func (s Four[TT, UU, VV, WW]) U() UU
- func (s Four[TT, UU, VV, WW]) V() VV
- func (s Four[TT, UU, VV, WW]) W() WW
- func (s Four[TT, UU, VV, WW]) Which() Which
- type Maybe
- func (m Maybe[T]) Empty() bool
- func (m Maybe[T]) Get() T
- func (m Maybe[T]) OrElse(elseVal T) T
- func (m Maybe[T]) OrError(e error) (res T, err error)
- func (m Maybe[T]) Present() bool
- func (m *Maybe[T]) Set(newVal T)
- func (m *Maybe[T]) SetEmpty()
- func (m *Maybe[T]) SetOrError(newVal T) error
- func (m Maybe[T]) String() string
- type Result
- type Three
- func (s *Three[TT, UU, VV]) SetT(t TT)
- func (s *Three[TT, UU, VV]) SetU(u UU)
- func (s *Three[TT, UU, VV]) SetV(v VV)
- func (s Three[TT, UU, VV]) String() string
- func (s Three[TT, UU, VV]) T() TT
- func (s Three[TT, UU, VV]) U() UU
- func (s Three[TT, UU, VV]) V() VV
- func (s Three[TT, UU, VV]) Which() Which
- type Two
- type Which
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Four ¶
type Four[T, U, V, W any] struct { // contains filtered or unexported fields }
Four is a union of four values
type Maybe ¶
type Maybe[T any] struct { // contains filtered or unexported fields }
Maybe is a wrapper around a single value that may or may not exist, as an alternative to a pointer or an Iter
func Of ¶
Of constructs a Maybe that holds a T. If t is nil, the Maybe is Empty, otherwise it is Present.
func (Maybe[T]) Get ¶
func (m Maybe[T]) Get() T
Get returns the value of the Maybe, which panics if it is not present
func (Maybe[T]) OrElse ¶
func (m Maybe[T]) OrElse(elseVal T) T
OrElse returns the value of the Maybe if present, or the else value provided if it is empty
func (Maybe[T]) OrError ¶
OrError returns (value of the Maybe, nil) if present, or (zero value of T, error provided) if not present
func (*Maybe[T]) Set ¶
func (m *Maybe[T]) Set(newVal T)
Set overwrites the current value with newVal, and sets m as present unless the newVal is a nil pointer
func (*Maybe[T]) SetEmpty ¶
func (m *Maybe[T]) SetEmpty()
SetEmpty overwrites the current value with the zero value, and sets m as empty
func (*Maybe[T]) SetOrError ¶
SetOrError sets the current value with val if empty, else returns an error if a present val has already been set
type Result ¶
type Result[R any] struct { // contains filtered or unexported fields }
Result is a variation of Two where the second value is predefined as an error
func OfResultError ¶
OfResultError constructs a Result from a value of type R and an error Panics if the error is non-nil and R is not the zero value
func (Result[R]) Error ¶
Error returns a nil error if there is a result, or a non-nil error if there is an error
func (Result[R]) Get ¶
func (r Result[R]) Get() R
Get returns an R if there is a result, or zero value if there is an error
type Three ¶
type Three[T, U, V any] struct { // contains filtered or unexported fields }
Three is a union of three values`