optional

package
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreAllEmpty

func AreAllEmpty[T any, N Nullable[T]](in ...N) bool

func AreAllFilled

func AreAllFilled[T any, N Nullable[T]](in ...N) bool

func Compare

func Compare[T constraints.Integer | constraints.Float, N Nullable[T]](a, b N) (int, T, T)

Compare compares A to B and returns

  • +1 if a > b
  • -1 if a < b
  • 0 if a = b or EITHER ONE is not set

func SomeFromTyped

func SomeFromTyped[T any, N Nullable[T]](nullable N) T

Types

type Native

type Native[U any] interface {
	Native() U
}

type Null

type Null[T any] struct {
	// contains filtered or unexported fields
}

func Empty

func Empty[T any]() Null[T]

func FromTyped

func FromTyped[T any, N Nullable[T]](nullable N) Null[T]

func GrpcToNull

func GrpcToNull[T, K any](in *T, convert func(in *T) K) Null[K]

func New

func New[T any](in T) Null[T]

func (Null[T]) Expect added in v1.0.46

func (n Null[T]) Expect(errMessage string) (T, error)

func (Null[T]) Filled

func (n Null[T]) Filled() bool

func (Null[T]) Get

func (n Null[T]) Get() (T, bool)

func (Null[T]) Grpc

func (n Null[T]) Grpc() *T

Grpc use only for conversion to protobuf struct

func (Null[T]) MarshalJSON

func (n Null[T]) MarshalJSON() ([]byte, error)

func (Null[T]) OrDefault

func (n Null[T]) OrDefault(d T) T

func (Null[T]) Some

func (n Null[T]) Some() T

func (Null[T]) String

func (n Null[T]) String() string

func (*Null[T]) UnmarshalJSON

func (n *Null[T]) UnmarshalJSON(data []byte) error

type Nullable

type Nullable[T any] interface {
	Get() (T, bool)
}

Jump to

Keyboard shortcuts

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