github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/convert/as/api.go (about) 1 // Package as provides as.Is alias 2 package as 3 4 import ( 5 "github.com/m4gshm/gollections/convert" 6 ) 7 8 // Is an alias of the convert.AsIs 9 func Is[T any](value T) T { return convert.AsIs(value) } 10 11 // Slice an alias of the convert.AsSlice 12 func Slice[T any](value T) []T { return convert.AsSlice(value) } 13 14 // ErrTail wraps a function of one argument and one result in a function that returns an error 15 func ErrTail[I, O any](f func(I) O) func(I) (O, error) { 16 return func(in I) (O, error) { return f(in), nil } 17 } 18 19 // Ptr converts a value to the value pointer 20 func Ptr[T any](value T) *T { return convert.Ptr(value) } 21 22 // Val returns a value referenced by the pointer or the zero value if the pointer is nil 23 func Val[T any](pointer *T) T { return convert.PtrVal(pointer) }