Documentation
¶
Overview ¶
Package ptr provides helpers for constructing pointers from values.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPtr ¶
func NewPtr[T any](t T) *T
NewPtr returns a pointer to a copy of t. Reference values retain their underlying references; NewPtr does not perform a deep copy.
Example ¶
package main
import (
"fmt"
"github.com/cohesian-tools/typy/ptr"
)
func main() {
original := 42
value := ptr.NewPtr(original)
*value = 7
fmt.Println(original, *value)
}
Output: 42 7
Types ¶
This section is empty.