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)
| 8 | // ValOrDefault returns the value of the given pointer as long as it's non-nil, |
| 9 | // and the specified default value otherwise. |
| 10 | func 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. |
no outgoing calls
searching dependent graphs…