Documentation
¶
Overview ¶
Package genericsutil provides helpers for implementing type erasure patterns
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertOrZero ¶
Returns v cast as type T if possible, otherwise returns the zero value of T
Types ¶
type AnyIOFunc ¶
type AnyIOFunc interface {
AnyZeroHelper
// If type assertion fails, implementation should still call the
// underlying function with the zero value of the input type.
ExecuteLoose(any) (any, error)
// If type assertion fails, implementation should return an error
// and the zero value of the input type, without calling the
// underlying function.
ExecuteStrict(any) (any, error)
}
type AnyZeroHelper ¶
type IOFunc ¶
func (IOFunc[I, O]) ExecuteLoose ¶
If type assertion fails, ExecuteLoose will still call the underlying function with the zero value of the input type.
func (IOFunc[I, O]) ExecuteStrict ¶
If type assertion fails, ExecuteStrict will return an error and the zero value of the input type, without calling the underlying function.
type ZeroHelper ¶
func (ZeroHelper[I, O]) I ¶
func (ZeroHelper[I, O]) I() any
func (ZeroHelper[I, O]) IPtr ¶
func (ZeroHelper[I, O]) IPtr() any
func (ZeroHelper[I, O]) O ¶
func (ZeroHelper[I, O]) O() any
func (ZeroHelper[I, O]) OPtr ¶
func (ZeroHelper[I, O]) OPtr() any
Click to show internal directories.
Click to hide internal directories.