Documentation ¶
Overview ¶
Package optional has optional types and functions used by Agent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Option represents an optional type. By default, no value is set and a call to Get() returns (T{}, false)
func MapOption ¶
MapOption returns fct(value) if a value is set, otherwise it returns NewNoneOption[T2]().
func NewNoneOption ¶
NewNoneOption creates a new instance of Option[T] without any value set.
func NewNoneOptionPtr ¶ added in v0.52.0
NewNoneOptionPtr creates a new instance of Option[T] without any value set.
func NewOption ¶
NewOption creates a new instance of Option[T] with a value set. A call to Get() will returns (value, true)
func NewOptionPtr ¶ added in v0.52.0
NewOptionPtr creates a new instance of Option[T] with a value set. A call to Get() will returns (value, true)
func (*Option[T]) Get ¶
Get returns the value and true if a value is set, otherwise it returns (undefined, false).
func (*Option[T]) SetIfNone ¶ added in v0.53.0
func (o *Option[T]) SetIfNone(value T)
SetIfNone sets the value if it is not already set. Does nothing if the current instance is already set.
func (*Option[T]) SetOptionIfNone ¶ added in v0.53.0
SetOptionIfNone sets the option if it is not already set. Does nothing if the current instance is already set.
func (*Option[T]) UnmarshalYAML ¶
UnmarshalYAML unmarshals an Option[T] from YAML