Documentation
¶
Index ¶
- type Field
- func AdoptPtr[T any](v *T) Field[T]
- func Filter[T any](in Field[T], pred func(T) bool) Field[T]
- func FlatMap[T, U any](in Field[T], f func(T) Field[U]) Field[U]
- func Map[T, U any](in Field[T], f func(T) U) Field[U]
- func NewField[T any](v T) Field[T]
- func NewFieldFromPtr[T any](v *T) Field[T]
- func None[T any]() Field[T]
- func (i *Field[T]) Clear()
- func (i *Field[T]) Get() (T, bool)
- func (i *Field[T]) If(fn func(T))
- func (i *Field[T]) IfPresentOrElse(fn func(T), elseFn func())
- func (i Field[T]) IsZero() bool
- func (i *Field[T]) MarshalJSON() ([]byte, error)
- func (i *Field[T]) MustGet() T
- func (i *Field[T]) OrElse(v T) T
- func (i *Field[T]) OrElseGet(supplier func() T) T
- func (i *Field[T]) Present() bool
- func (i *Field[T]) Ref() (*T, bool)
- func (i *Field[T]) Set(v T)
- func (i Field[T]) String() string
- func (i *Field[T]) ToPtr() *T
- func (i *Field[T]) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field[T any] struct { // contains filtered or unexported fields }
func AdoptPtr ¶
AdoptPtr creates a Field[T] that references the provided pointer directly. Mutations through the returned reference will affect the original value.
func NewFieldFromPtr ¶
func (*Field[T]) IfPresentOrElse ¶
func (i *Field[T]) IfPresentOrElse(fn func(T), elseFn func())
IfPresentOrElse executes fn if present, otherwise elseFn.
func (*Field[T]) MarshalJSON ¶
func (*Field[T]) OrElseGet ¶
func (i *Field[T]) OrElseGet(supplier func() T) T
OrElseGet returns the contained value if present, otherwise uses supplier.
func (*Field[T]) Ref ¶
Ref returns the internal pointer and whether it is present. Mutating through the returned pointer (when ok) affects the stored value.
func (*Field[T]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.