1package param
2
3import "github.com/openai/openai-go/internal/encoding/json/sentinel"
4
5// NullMap returns a non-nil map with a length of 0.
6// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
7//
8// It is unspecified behavior to mutate the map returned by [NullMap].
9func NullMap[MapT ~map[string]T, T any]() MapT {
10 return sentinel.NewNullSentinel(func() MapT { return make(MapT, 1) })
11}
12
13// NullSlice returns a non-nil slice with a length of 0.
14// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
15//
16// It is unspecified behavior to mutate the slice returned by [NullSlice].
17func NullSlice[SliceT ~[]T, T any]() SliceT {
18 return sentinel.NewNullSentinel(func() SliceT { return make(SliceT, 0, 1) })
19}