MCPcopy Index your code
hub / github.com/riverqueue/river / ValOrDefault

Function ValOrDefault

rivershared/util/ptrutil/ptr_util.go:10–15  ·  view source on GitHub ↗

ValOrDefault returns the value of the given pointer as long as it's non-nil, and the specified default value otherwise.

(ptr *T, defaultVal T)

Source from the content-addressed store, hash-verified

8// ValOrDefault returns the value of the given pointer as long as it's non-nil,
9// and the specified default value otherwise.
10func ValOrDefault[T any](ptr *T, defaultVal T) T {
11 if ptr != nil {
12 return *ptr
13 }
14 return defaultVal
15}
16
17// ValOrDefaultFunc returns the value of the given pointer as long as it's
18// non-nil, or invokes the given function to produce a default value otherwise.

Callers 11

Job_BuildFunction · 0.92
LeaderFunction · 0.92
MigrationFunction · 0.92
JobInsertFastManyMethod · 0.92
JobInsertFullManyMethod · 0.92
JobRescueManyMethod · 0.92
JobInsertFastManyMethod · 0.92
JobInsertFullManyMethod · 0.92
JobRescueManyMethod · 0.92
jobRowFromInternalFunction · 0.92
TestValOrDefaultFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestValOrDefaultFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…