opt

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 0 Imported by: 20

Documentation

Overview

Package opt provides utilities for optional types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

type T[D any] struct {

	// Specified indicates whether Value can be used.
	Specified bool

	// Value holds the actual value.
	Value D
}

func FromPtr added in v0.4.0

func FromPtr[D any](value *D) T[D]

FromPtr returns an optional T value which is specified depending on whether the pointer can be dereferenced or not.

func Unspecified

func Unspecified[D any]() T[D]

Unspecified returns an unspecified value of the generic type.

func V

func V[D any](value D) T[D]

V returns a specified value of the generic type.

func (T[D]) ToPtr added in v0.4.0

func (t T[D]) ToPtr() *D

ToPtr returns a pointer-based representation of the value held in this optional. If this optional is not specified, then nil is returned.

Jump to

Keyboard shortcuts

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