MCPcopy Index your code
hub / github.com/coder/coder / NilToDefault

Function NilToDefault

coderd/util/ptr/ptr.go:30–35  ·  view source on GitHub ↗

NilToDefault coalesces a nil value to the provided default value.

(s *T, def T)

Source from the content-addressed store, hash-verified

28
29// NilToDefault coalesces a nil value to the provided default value.
30func NilToDefault[T any](s *T, def T) T {
31 if s == nil {
32 return def
33 }
34 return *s
35}
36
37// NilOrZero returns true if v is nil or 0.
38func NilOrZero[T number](v *T) bool {

Callers 5

aiProvidersUpdateMethod · 0.92
recordManualTitleUsageFunction · 0.92
Test_NilToDefaultFunction · 0.92

Calls

no outgoing calls

Tested by 1

Test_NilToDefaultFunction · 0.74