common: merge all *ToPtr methods to one generic ToPtr
After introducing Go 1.18 to a project, it's required by law to convert at least one method to a generic one. Everyone hates IntToPtr, StringToPtr, BoolToPtr and Uint64ToPtr, so let's convert them to the ultimate generic ToPtr one. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
0359647a82
commit
b997142db0
46 changed files with 397 additions and 392 deletions
|
|
@ -1,17 +1,5 @@
|
|||
package common
|
||||
|
||||
func IntToPtr(x int) *int {
|
||||
return &x
|
||||
}
|
||||
|
||||
func Uint64ToPtr(x uint64) *uint64 {
|
||||
return &x
|
||||
}
|
||||
|
||||
func BoolToPtr(x bool) *bool {
|
||||
return &x
|
||||
}
|
||||
|
||||
func StringToPtr(x string) *string {
|
||||
func ToPtr[T any](x T) *T {
|
||||
return &x
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue