Skip to content

Commit

Permalink
util: Add a generic ToPtr function
Browse files Browse the repository at this point in the history
New Azure SDK API requires using pointers to a much greater degree
than old API, so it won't be limited to strings and booleans.
  • Loading branch information
krnowak committed Jun 19, 2024
1 parent 8dbe70b commit c0d68cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
package util

func StrToPtr(s string) *string {
return &s
return ToPtr(s)
}

func BoolToPtr(b bool) *bool {
return &b
return ToPtr(b)
}

func ToPtr[T any](v T) *T {
return &v
}

0 comments on commit c0d68cd

Please sign in to comment.