Documentation ¶
Index ¶
- func Try(action func()) error
- type Value
- func Access[OBJ, F any](opt Value[OBJ], field string) Value[F]
- func Copy[T any](opt Value[T]) Value[T]
- func Missing[T any]() Value[T]
- func Nil[T any]() Value[T]
- func Some[T any](val T) Value[T]
- func TryErr[T any](action func() T) (ret Value[T], err error)
- func TryExpr[T any](action func() T) (ret Value[T])
- func (opt Value[T]) Eq(val T) bool
- func (opt Value[T]) EqOpt(val Value[T]) bool
- func (opt Value[T]) HasValue() bool
- func (opt Value[T]) LookupValue() (T, bool)
- func (opt Value[T]) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (opt Value[T]) MarshalJSON() ([]byte, error)
- func (opt *Value[T]) Set(val T)
- func (opt *Value[T]) SetNil()
- func (opt Value[T]) String() string
- func (opt *Value[T]) UnmarshalBSONValue(t bsontype.Type, data []byte) (err error)
- func (opt *Value[T]) UnmarshalJSON(data []byte) error
- func (opt Value[T]) Value() T
- func (opt Value[T]) ValueOr(val T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
Value[T] is an optional value of type T, meaning it can represent the lack of value.
func Copy ¶ added in v0.0.8
Copy allows to make a deep copy of optional.Value. optional.Values share references by default.
func Nil ¶ added in v0.0.6
Nil is a function to make an optional.Value without a value; it is equivalent to optional.Value's zero value
func (Value[T]) LookupValue ¶
LookupValue return the containing value value or the a zero value if the optional.Value doesn't have a value, and a boolean to true if it contains a value
func (Value[T]) MarshalBSONValue ¶
func (Value[T]) MarshalJSON ¶
func (*Value[T]) Set ¶
func (opt *Value[T]) Set(val T)
Set allows to set a value to the optional.Value
func (*Value[T]) SetNil ¶
func (opt *Value[T]) SetNil()
SetNil allows to set "nil" to the optional.Value, meaning it remove the value from it
func (*Value[T]) UnmarshalBSONValue ¶
func (*Value[T]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.