Documentation
¶
Index ¶
- Variables
- func BoolToInt(b bool) int
- func CastFloat[T, V constraints.Float](v V) T
- func CastInteger[T, V constraints.Integer](v V) T
- func CastNumber[T, V constraintsi.Number](v V) T
- func CastSigned[T, V constraints.Signed](v V) T
- func CastUnsigned[T, V constraints.Unsigned](v V) T
- func ResultVal[T any](v T, err error) T
- type Basic
- type BinaryFunction
- type BinaryKVFunction
- type BinaryKVFunction2
- type BinaryKVOperator
- type BinaryOperator
- type Bool
- func (b Bool) IsFalse() bool
- func (b Bool) IsNone() bool
- func (b Bool) IsTrue() bool
- func (b Bool) MarshalBinary() ([]byte, error)
- func (b Bool) MarshalJSON() ([]byte, error)
- func (b Bool) MarshalText() ([]byte, error)
- func (b Bool) String() string
- func (b *Bool) UnmarshalBinary(data []byte) error
- func (b *Bool) UnmarshalJSON(data []byte) error
- func (b *Bool) UnmarshalText(data []byte) error
- type Comparator
- type ComparatorKV
- type Consumer
- type ConsumerKV
- type Dict
- type Enum
- type Func
- type FuncRetry
- type FuncReturnDataOrErr
- type FuncReturnErr
- type ID
- type Int
- type Less
- type LessKV
- type Option
- func (opt *Option[T]) Get() (T, bool)
- func (opt *Option[T]) IfNone(action func())
- func (opt *Option[T]) IfSome(action func(value T))
- func (opt *Option[T]) IsNone() bool
- func (opt *Option[T]) IsSome() bool
- func (opt *Option[T]) MarshalJSON() ([]byte, error)
- func (opt *Option[T]) UnmarshalJSON(data []byte) error
- func (opt *Option[T]) Unwrap() T
- func (opt *Option[T]) UnwrapOr(def T) T
- func (opt *Option[T]) UnwrapOrElse(fn func() T) T
- func (opt *Option[T]) Val() (T, bool)
- type OptionPtr
- func (opt OptionPtr[T]) Get() (*T, bool)
- func (opt OptionPtr[T]) IfNone(action func())
- func (opt OptionPtr[T]) IfSome(action func(value *T))
- func (opt OptionPtr[T]) IsNone() bool
- func (opt OptionPtr[T]) IsSome() bool
- func (opt OptionPtr[T]) MarshalJSON() ([]byte, error)
- func (opt *OptionPtr[T]) UnmarshalJSON(data []byte) error
- func (opt OptionPtr[T]) Unwrap() *T
- func (opt OptionPtr[T]) UnwrapOr(def *T) *T
- func (opt OptionPtr[T]) UnwrapOrElse(fn func() *T) *T
- func (opt OptionPtr[T]) Val() (*T, bool)
- type Pair
- type Predicate
- type PredicateKV
- type Ref
- type Result
- func (a Result[T]) IfErr(action func(err error))
- func (a Result[T]) IfOk(action func(value T))
- func (a Result[T]) IsErr() bool
- func (a Result[T]) IsErrAnd(f func(error) bool) bool
- func (a Result[T]) IsOk() bool
- func (a Result[T]) IsOkAnd(f func(T) bool) bool
- func (a *Result[T]) MarshalJSON() ([]byte, error)
- func (a Result[T]) Or(value T) T
- func (a Result[T]) OrDefault() (v T)
- func (a Result[T]) OrPanic() T
- func (a *Result[T]) UnmarshalJSON(data []byte) error
- func (a Result[T]) Val() (value T, err error)
- type Service
- type String
- type Supplier
- type SupplierKV
- type Task
- type TaskReturnErr
- type Tuple
- type UnaryFunction
- type UnaryKVFunction
- type UnaryKVFunction2
- type UnaryKVOperator
- type UnaryOperator
Constants ¶
This section is empty.
Variables ¶
var EmptyStruct = struct{}{}
Functions ¶
func CastInteger ¶
func CastInteger[T, V constraints.Integer](v V) T
CastInteger converts the value.
func CastUnsigned ¶
func CastUnsigned[T, V constraints.Unsigned](v V) T
CastUnsigned converts the value.
Types ¶
type BinaryFunction ¶
type BinaryFunction[T, R, U any] func(T, R) U
BinaryFunction converts two inputs to a third type.
type BinaryKVFunction ¶
type BinaryKVFunction[K, V, R, U any] func(K, V, R) U
type BinaryKVFunction2 ¶
type BinaryKVFunction2[K, V, RK, RV, UK, UV any] func(K, V, RK, RV) (UK, UV)
type BinaryKVOperator ¶
type BinaryKVOperator[K, V any] func(K, V, K, V) (K, V)
type BinaryOperator ¶
type BinaryOperator[T any] func(T, T) T
BinaryOperator applies a binary operation to two values of the same type and returns the same type.
type Bool ¶
type Bool int8
func (Bool) MarshalJSON ¶
MarshalJSON encodes the value.
func (*Bool) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Bool) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Comparator ¶
Comparator compares two elements. If the first element is greater than the second, it returns a positive number; if the first element is less than the second, it returns a negative number; otherwise it returns 0.
type ComparatorKV ¶
Comparator compares two elements. If the first element is greater than the second, it returns a positive number; if the first element is less than the second, it returns a negative number; otherwise it returns 0.
type Dict ¶
type Dict[K comparable, V any] struct { Key K Value V }
type Enum ¶
type Enum[T constraintsi.Enum] int32
func (Enum[T]) MarshalJSON ¶
MarshalJSON encodes the value.
func (Enum[T]) MarshalText ¶
MarshalText encodes the value.
func (*Enum[T]) UnmarshalJSON ¶
UnmarshalJSON decodes into the value.
func (*Enum[T]) UnmarshalText ¶
UnmarshalText decodes into the value.
type FuncReturnDataOrErr ¶
type FuncReturnErr ¶
type FuncReturnErr func() error
type ID ¶
type ID[T constraintsi.ID] struct { Id T `json:"id"` }
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Returning an Option can copy the value multiple times; decide whether you need it.
func (*Option[T]) IfNone ¶
func (opt *Option[T]) IfNone(action func())
IfNone runs action if the Option is empty.
func (*Option[T]) IfSome ¶
func (opt *Option[T]) IfSome(action func(value T))
IfSome runs action if the Option contains a value.
func (*Option[T]) MarshalJSON ¶
MarshalJSON encodes the value, or null if the Option is empty.
func (*Option[T]) UnmarshalJSON ¶
UnmarshalJSON decodes the value, or leaves the Option empty for null.
func (*Option[T]) Unwrap ¶
func (opt *Option[T]) Unwrap() T
Unwrap returns the value or panics if the Option is empty.
func (*Option[T]) UnwrapOr ¶
func (opt *Option[T]) UnwrapOr(def T) T
UnwrapOr returns the value or def if the Option is empty.
func (*Option[T]) UnwrapOrElse ¶
func (opt *Option[T]) UnwrapOrElse(fn func() T) T
UnwrapOrElse returns the value or calls fn if the Option is empty.
type OptionPtr ¶
type OptionPtr[T any] struct { // contains filtered or unexported fields }
func MapOptionPtr ¶
MapOptionPtr maps the contained value to another pointer type.
func (OptionPtr[T]) IfNone ¶
func (opt OptionPtr[T]) IfNone(action func())
IfNone runs action if the OptionPtr is empty.
func (OptionPtr[T]) IfSome ¶
func (opt OptionPtr[T]) IfSome(action func(value *T))
IfSome runs action if the OptionPtr contains a value.
func (OptionPtr[T]) MarshalJSON ¶
MarshalJSON encodes the value, or null if the OptionPtr is empty.
func (*OptionPtr[T]) UnmarshalJSON ¶
UnmarshalJSON decodes the value, or leaves the OptionPtr empty for null.
func (OptionPtr[T]) Unwrap ¶
func (opt OptionPtr[T]) Unwrap() *T
Unwrap returns the value or panics if the OptionPtr is empty.
func (OptionPtr[T]) UnwrapOr ¶
func (opt OptionPtr[T]) UnwrapOr(def *T) *T
UnwrapOr returns the value or def if the OptionPtr is empty.
func (OptionPtr[T]) UnwrapOrElse ¶
func (opt OptionPtr[T]) UnwrapOrElse(fn func() *T) *T
UnwrapOrElse returns the value or calls fn if the OptionPtr is empty.
type PredicateKV ¶
Predicate checks whether a key/value pair satisfies a condition.
type Ref ¶
type Ref[T any] struct { // contains filtered or unexported fields }
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
func (*Result[T]) MarshalJSON ¶
MarshalJSON encodes the value.
func (*Result[T]) UnmarshalJSON ¶
UnmarshalJSON decodes into the value.
type TaskReturnErr ¶ added in v1.11.3
type UnaryFunction ¶
type UnaryFunction[T, R any] func(T) R
UnaryFunction converts a value from one type to another.
type UnaryKVFunction ¶
type UnaryKVFunction[K, V, R any] func(K, V) R
UnaryKVFunction converts a key/value pair to another value.
type UnaryKVFunction2 ¶
type UnaryKVFunction2[K, V, RK, RV any] func(K, V) (RK, RV)
type UnaryKVOperator ¶
type UnaryKVOperator[K, V any] func(K, V) (K, V)
type UnaryOperator ¶
type UnaryOperator[T any] func(T) T
UnaryOperator applies a unary operation and returns a value of the same type.