Skip to content

Commit 7b0ae9e

Browse files
committed
Backport generic Ptr helper func
1 parent 86e8e43 commit 7b0ae9e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

base/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,12 @@ func LogLevelPtr(value LogLevel) *LogLevel {
851851
return &value
852852
}
853853

854+
// Ptr returns a pointer to the given literal.
855+
// This is useful for wrapping around function calls that return a value, where you can't just use `&`.
856+
func Ptr[T any](v T) *T {
857+
return &v
858+
}
859+
854860
// StringPtr returns a pointer to the given string literal.
855861
func StringPtr(value string) *string {
856862
return &value

0 commit comments

Comments
 (0)