Path: blob/main/vendor/github.com/google/go-cmp/cmp/internal/value/pointer.go
2898 views
// Copyright 2018, The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34package value56import (7"reflect"8"unsafe"9)1011// Pointer is an opaque typed pointer and is guaranteed to be comparable.12type Pointer struct {13p unsafe.Pointer14t reflect.Type15}1617// PointerOf returns a Pointer from v, which must be a18// reflect.Ptr, reflect.Slice, or reflect.Map.19func PointerOf(v reflect.Value) Pointer {20// The proper representation of a pointer is unsafe.Pointer,21// which is necessary if the GC ever uses a moving collector.22return Pointer{unsafe.Pointer(v.Pointer()), v.Type()}23}2425// IsNil reports whether the pointer is nil.26func (p Pointer) IsNil() bool {27return p.p == nil28}2930// Uintptr returns the pointer as a uintptr.31func (p Pointer) Uintptr() uintptr {32return uintptr(p.p)33}343536