option

package
v0.0.0-...-08e1117 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigOptional

type ConfigOptional[T primatives] interface {
	Optional[T]

	// Satisfies encoding.TextUnmarshaler
	UnmarshalText(text []byte) error
}

type NoneError

type NoneError struct {
	// contains filtered or unexported fields
}

func NewNoneError

func NewNoneError(msg string) *NoneError

func (NoneError) Error

func (e NoneError) Error() string

type Option

type Option[T comparable] struct {
	// contains filtered or unexported fields
}

func None

func None[T comparable]() Option[T]

func Some

func Some[T comparable](value T) Option[T]

func (*Option[T]) BinaryTransform

func (o *Option[T]) BinaryTransform(second T, f func(T, T) (T, error)) error

func (*Option[T]) Clear

func (o *Option[T]) Clear()

func (Option[T]) Eq

func (o Option[T]) Eq(other Optional[T]) bool

func (Option[T]) IsNone

func (o Option[T]) IsNone() bool

func (Option[T]) IsSome

func (o Option[T]) IsSome() bool

func (Option[T]) Match

func (o Option[T]) Match(probe T) bool

func (*Option[T]) Set

func (o *Option[T]) Set(value T)

func (*Option[T]) Transform

func (o *Option[T]) Transform(f func(T) (T, error)) error

func (*Option[T]) TransformOr

func (o *Option[T]) TransformOr(f func(T) (T, error), backup T)

func (*Option[T]) TransformOrElse

func (o *Option[T]) TransformOrElse(f func(T) (T, error), backup func() T)

func (*Option[T]) UnmarshalJSON

func (o *Option[T]) UnmarshalJSON(data []byte) error

Unmarshaller interface

func (*Option[T]) UnsafeUnwrap

func (o *Option[T]) UnsafeUnwrap() T

func (*Option[T]) Unwrap

func (o *Option[T]) Unwrap() (T, error)

func (*Option[T]) UnwrapOrDefault

func (o *Option[T]) UnwrapOrDefault(def T) T

func (*Option[T]) UnwrapOrElse

func (o *Option[T]) UnwrapOrElse(f func() T) T

type Optional

type Optional[T comparable] interface {
	IsSome() bool
	IsNone() bool
	Clear()
	Set(T)
	Unwrap() (T, error)
	UnsafeUnwrap() T
	UnwrapOrDefault(T) T
	UnwrapOrElse(func() T) T
	Match(T) bool
	Eq(Optional[T]) bool
	Transform(func(T) (T, error)) error
	TransformOr(func(T) (T, error), T)
	TransformOrElse(func(T) (T, error), func() T)
	BinaryTransform(second T, f func(T, T) error) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL