1package paramutil
2
3import (
4 "github.com/anthropics/anthropic-sdk-go/internal/encoding/json/sentinel"
5)
6
7// NullPtr returns a pointer to the zero value of the type T.
8// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
9//
10// It is unspecified behavior to mutate the value pointed to by the returned pointer.
11func NullPtr[T any]() *T {
12 return sentinel.NullPtr[T]()
13}
14
15// IsNullPtr returns true if the pointer was created by [NullPtr].
16func IsNullPtr[T any](ptr *T) bool {
17 return sentinel.IsNullPtr(ptr)
18}
19
20// NullSlice returns a non-nil slice with a length of 0.
21// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
22//
23// It is undefined behavior to mutate the slice returned by [NullSlice].
24func NullSlice[T any]() []T {
25 return sentinel.NullSlice[T]()
26}
27
28// IsNullSlice returns true if the slice was created by [NullSlice].
29func IsNullSlice[T any](slice []T) bool {
30 return sentinel.IsNullSlice(slice)
31}