package ptr
import "go.mau.fi/util/ptr"
Index ¶
- func Clone[T any](val *T) *T
- func NonDefault[T comparable](val, def T) *T
- func NonZero[T comparable](val T) *T
- func Ptr[T any](val T) *T
- func Val[T any](ptr *T) (val T)
Functions ¶
func Clone ¶
func Clone[T any](val *T) *T
Clone creates a shallow copy of the given pointer.
func NonDefault ¶
func NonDefault[T comparable](val, def T) *T
NonDefault returns a pointer to the first parameter, unless it is equal to the second parameter.
func NonZero ¶
func NonZero[T comparable](val T) *T
NonZero returns a pointer to the given comparable value, unless the value is the type's zero value.
func Ptr ¶
func Ptr[T any](val T) *T
Ptr returns a pointer to the given value.
func Val ¶
func Val[T any](ptr *T) (val T)
Val returns the value of the given pointer, or the zero value of the type if the pointer is nil.
Source Files ¶
ptr.go
- Version
- v0.8.6 (latest)
- Published
- Mar 16, 2025
- Platform
- linux/amd64
- Last checked
- 1 week ago –
Tools for package owners.