ptr

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: ISC Imports: 0 Imported by: 0

Documentation

Overview

Package ptr contains helper types and functions for working with optional types as pointers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValueOrDefault

func ValueOrDefault[T any](o Optional[T], def T) T

ValueOrDefault returns the value or the given default if not set.

func ValueOrZero

func ValueOrZero[T any](o Optional[T]) T

ValueOrZero returns the value or the zero value if not set.

Types

type Optional

type Optional[T any] *T

Optional indicates that a type may be omitted if null using `omitzero`.

func To

func To[T any](v T) Optional[T]

To creates a new Optional value wrapping the given value.

Jump to

Keyboard shortcuts

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