mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 04:40:05 -06:00
* 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
39 lines
637 B
Go
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
|
|
}
|