Documentation ¶
Index ¶
- func Cast[T any](o any) T
- func CastPointer[I any, E any, P PointerType[E]](e P) I
- func CastPointerR[I any, E any, P PointerType[E]](e P, err error) (I, error)
- func CastR[T any](o any, err error) (T, error)
- func Pointer[T any](t T) *T
- func TryCast[T any](o any) (T, bool)
- func TryCastE[T any](o any) (T, error)
- func TypeOf[T any]() reflect.Type
- type PointerType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cast ¶
Cast asserts a type given by a type parameter for a value This is not directly suppoerted by Go.
func [O any](...) { x := i.(O) }
func CastPointer ¶
func CastPointer[I any, E any, P PointerType[E]](e P) I
CastPointer maps a pointer P to an interface type I avoiding typed nil pointers. Nil pointers will be mapped to nil interfaces.
func CastPointerR ¶
func CastPointerR[I any, E any, P PointerType[E]](e P, err error) (I, error)
CastPointerR maps a pointer P to an interface type I for a factory function with an additional error result avoiding typed nil pointers. Nil pointers will be mapped to nil interfaces.
func CastR ¶
CastR cast a result type to a dedicated Type T for a factory function with an additional error result Nil will be mapped to the initial value of the target type
Types ¶
type PointerType ¶
type PointerType[P any] interface { *P }
Click to show internal directories.
Click to hide internal directories.