Documentation ¶
Index ¶
- type Maybe
- func (m Maybe[T]) Get(fallback T) T
- func (m Maybe[T]) HasValue() bool
- func (m Maybe[T]) IsZero() bool
- func (m Maybe[T]) MarshalJSON() ([]byte, error)
- func (m Maybe[T]) MarshalYAML() (any, error)
- func (m Maybe[T]) MustGet() T
- func (m Maybe[T]) None() Maybe[T]
- func (m *Maybe[T]) Scan(value any) error
- func (m *Maybe[T]) UnmarshalEnvironmentValue(data string) error
- func (m *Maybe[T]) UnmarshalJSON(data []byte) error
- func (m *Maybe[T]) UnmarshalYAML(value *yaml.Node) error
- func (m Maybe[T]) Value() (driver.Value, error)
- func (m Maybe[T]) WithValue(value T) Maybe[T]
- type Patch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Maybe ¶
type Maybe[T any] struct { // contains filtered or unexported fields }
Represents an optional value of type T. It implements some infrastructure interfaces such as JSON (un)marshalling and database convert.
This is much more clean than using pointers to express optional values.
func (Maybe[T]) Get ¶
func (m Maybe[T]) Get(fallback T) T
Retrieve the inner value or the fallback if it doesn't have one.
func (Maybe[T]) MarshalJSON ¶
func (Maybe[T]) MarshalYAML ¶ added in v1.0.1
func (Maybe[T]) MustGet ¶
func (m Maybe[T]) MustGet() T
Retrieve the inner value and panic if none is set.
func (*Maybe[T]) UnmarshalEnvironmentValue ¶ added in v1.0.1
func (*Maybe[T]) UnmarshalJSON ¶
func (*Maybe[T]) UnmarshalYAML ¶ added in v1.0.1
type Patch ¶
Type used to patch data. Those values could be set, nil or have a value.
func PatchValue ¶
Builds a new patch with the given value.
func (*Patch[T]) UnmarshalJSON ¶
Implements the UnmarshalJSON interface.
Click to show internal directories.
Click to hide internal directories.