MCPcopy Create free account
hub / github.com/cogentcore/core / PointerValue

Function PointerValue

base/reflectx/pointers.go:32–42  ·  view source on GitHub ↗

PointerValue returns a pointer to the given value if it is not already a pointer.

(v reflect.Value)

Source from the content-addressed store, hash-verified

30// PointerValue returns a pointer to the given value if it is not already
31// a pointer.
32func PointerValue(v reflect.Value) reflect.Value {
33 if v.Kind() == reflect.Pointer {
34 return v
35 }
36 if v.CanAddr() {
37 return v.Addr()
38 }
39 pv := reflect.New(v.Type())
40 pv.Elem().Set(v)
41 return pv
42}
43
44// OnePointerValue returns a value that is exactly one pointer away
45// from a non-pointer value.

Callers 3

addFieldsImplFunction · 0.92
CopySliceRobustFunction · 0.85
SetFromDefaultTagsFunction · 0.85

Calls 5

KindMethod · 0.80
ElemMethod · 0.80
NewMethod · 0.65
TypeMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected