// AllPtrFieldsNil tests whether all pointer fields in a struct are nil. This is useful when, // for example, an API struct is handled by plugins which need to distinguish // "no plugin accepted this spec" from "this spec is empty". // // This function is only valid for structs and pointers to structs. Any other // type will cause a panic. Passing a typed nil pointer will return true. func AllPtrFieldsNil(obj interface{ … } // To returns a pointer to the given value. func To[T any](v T) *T { … } // Deref dereferences ptr and returns the value it points to if no nil, or else // returns def. func Deref[T any](ptr *T, def T) T { … } // Equal returns true if both arguments are nil or both arguments // dereference to the same value. func Equal[T comparable](a, b *T) bool { … }