Initial QSfera import

This commit is contained in:
Курнат Андрей
2026-06-07 10:20:04 +03:00
commit 2315f25754
16485 changed files with 4826827 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package conversions
// ToPointer converts a value to a pointer
func ToPointer[T any](val T) *T {
return &val
}
// ToValue converts a pointer to a value
func ToValue[T any](ptr *T) T {
if ptr == nil {
var t T
return t
}
return *ptr
}
// ToPointerSlice converts a slice of values to a slice of pointers
func ToPointerSlice[E any](s []E) []*E {
rs := make([]*E, len(s))
for i, v := range s {
rs[i] = ToPointer(v)
}
return rs
}
// ToValueSlice converts a slice of pointers to a slice of values
func ToValueSlice[E any](s []*E) []E {
rs := make([]E, len(s))
for i, v := range s {
rs[i] = ToValue(v)
}
return rs
}