optional

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 2 Imported by: 0

README

optional

generic optional type for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToPtr

func ToPtr[T any](val T) *T

ToPtr returns the pointer of a copy of any given value

Types

type Option

type Option[T any] []T

func FromNonDefault

func FromNonDefault[T comparable](v T) Option[T]

func FromPtr

func FromPtr[T any](v *T) Option[T]

func None

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

func Some

func Some[T any](v T) Option[T]

func (Option[T]) Has

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

func (Option[T]) MarshalJSON

func (o Option[T]) MarshalJSON() ([]byte, error)

func (Option[T]) MarshalYAML

func (o Option[T]) MarshalYAML() (interface{}, error)

func (*Option[T]) UnmarshalJSON

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

func (*Option[T]) UnmarshalYAML

func (o *Option[T]) UnmarshalYAML(value *yaml.Node) error

func (Option[T]) Value

func (o Option[T]) Value() T

func (Option[T]) ValueOrDefault

func (o Option[T]) ValueOrDefault(v T) T

Jump to

Keyboard shortcuts

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