nullable

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Null

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

Null is a generic type that represents a nullable value. There are 2 possible states:

  • Null: > value: zero value of T > valid: false
  • Not Null: > value: value of T > valid: true

func None

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

Constructors None returns a Null[T] with valid set to false.

func Some

func Some[T any](value T) Null[T]

Some returns a Null[T] with valid set to true.

func (Null[T]) IsNull

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

Methods - Inspection IsNull returns true if the Null is in a Null state.

func (Null[T]) Unwrap

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

- Fetching Unwrap returns the inner value of a Not Null. If the Null is in a Null state, Unwrap panics.

Jump to

Keyboard shortcuts

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