Documentation ¶
Index ¶
- 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 Match[T any](yes bool, a, b T) T
- func ResultVal[T any](v T, err error) T
- func Zero[T any]() T
- func Zero2[T any]() T
- type Basic
- 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 Dict
- type Enum
- type ID
- type Int
- 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 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 String
- type Tuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CastFloat ¶
func CastFloat[T, V constraints.Float](v V) T
func CastInteger ¶
func CastInteger[T, V constraints.Integer](v V) T
func CastNumber ¶
func CastNumber[T, V constraintsi.Number](v V) T
func CastSigned ¶
func CastSigned[T, V constraints.Signed](v V) T
func CastUnsigned ¶
func CastUnsigned[T, V constraints.Unsigned](v V) T
Types ¶
type Bool ¶
type Bool int8
func (Bool) MarshalJSON ¶
func (*Bool) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Bool) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Dict ¶
type Dict[K comparable, V any] struct { Key K Value V }
type Enum ¶
type Enum[T constraints.Unsigned | ~string] struct { Value T }
type ID ¶
type ID[T constraintsi.ID] struct { Id T `json:"id"` }
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
返回option 返回时会有两次复制value,后续使用还有可能更多次,自行选择用不用
func (*Option[T]) MarshalJSON ¶
func (*Option[T]) UnmarshalJSON ¶
func (*Option[T]) UnwrapOrElse ¶
func (opt *Option[T]) UnwrapOrElse(fn func() T) T
type OptionPtr ¶ added in v0.1.0
type OptionPtr[T any] struct { // contains filtered or unexported fields }
func MapOptionPtr ¶ added in v0.1.0
func (OptionPtr[T]) MarshalJSON ¶ added in v0.1.0
func (*OptionPtr[T]) UnmarshalJSON ¶ added in v0.1.0
func (OptionPtr[T]) UnwrapOrElse ¶ added in v0.1.0
func (opt OptionPtr[T]) UnwrapOrElse(fn func() *T) *T
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
func (*Result[T]) MarshalJSON ¶
func (*Result[T]) UnmarshalJSON ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.