Files
opencloud/ocis-pkg/conversions/ptr.go
Florian Schade ad06a192d8 enhancement: add graph beta listPermissions endpoint (#7753)
* enhancement: add graph beta listPermissions endpoint

besides the new api endpoint it includes several utilities to simplify the graph api development.

* resolve drive and item id from the request path
* generic pointer and value utilities
* space root detection

* update GetDriveAndItemIDParam signature to return a error

* move errorcode package

* enhancement: add generic error code handling

* fix: rebase
2023-11-28 17:06:04 +01:00

39 lines
637 B
Go

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
}