package ptr
import "github.com/datastax/astra-db-go/v2/astra/ptr"
Package ptr provides helper functions for working with pointers.
Index
Functions
func From
func From[T any](ptr *T) T
From returns the value pointed to by ptr, or the zero value of T if ptr is nil.
Example usage:
isBlocking := ptr.From(opts.Blocking)
func FromWithDefault
func FromWithDefault[T any](ptr *T, fallback T) T
FromWithDefault returns the value pointed to by ptr, or the provided fallback if ptr is nil.
Example usage:
interval := ptr.FromWithDefault(myPtr, 5 * time.Second)
func To
func To[T any](v T) *T
To returns a pointer to the value passed in. This is to help with verbose code like:
blocking := true opts.Blocking = &blocking
Example usage:
opts.Blocking = ptr.To(true)