Documentation ¶
Overview ¶
Package Helpers provides a set of helper functions and types that can be used for automatic error handling and result evaluation.
However, this is still Work In Progress and is not yet fully implemented.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EvalFunc ¶ added in v0.2.32
EvalFunc is a generic type that represents a function that returns a value and an error.
Returns:
- T: The result of the function evaluation.
- error: The error that occurred during the function evaluation.
type EvalManyFunc ¶ added in v0.2.32
EvalManyFunc is a generic type that represents a function that returns multiple values and an error.
Returns:
- []T: The result of the function evaluation.
- error: The error that occurred during the function evaluation.
type HResult ¶
type HResult[T any] struct { // Result is the result of the function evaluation. Result T // Reason is the error that occurred during the function evaluation. Reason error }
HResult is a generic type that represents the result of a function evaluation.
func EvaluateFunc ¶
EvaluateFunc evaluates a function and returns the result as an HResult.
Parameters:
- f: The function to evaluate.
Returns:
- HResult: The result of the function evaluation.
func EvaluateMany ¶
func EvaluateMany[T any](f EvalManyFunc[T]) []HResult[T]
EvaluateMany evaluates a function that returns multiple values and returns the results as an array of HResults.
Parameters:
- f: The function to evaluate.
Returns:
- []HResult: The results of the function evaluation.
func NewHResult ¶
NewHResult creates a new HResult with the given result and reason.
Parameters:
- result: The result of the function evaluation.
- reason: The error that occurred during the function evaluation.
Returns:
- HResult: The new HResult.