Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
Result represents either a success value or an error.
Example:
r := result.Ok(42)
if r.IsOk() { ... }
func Map ¶
Map transforms the value if successful.
Example:
r := result.Ok(10)
r2 := result.Map(r, func(i int) string { return strconv.Itoa(i) })
func (Result[T]) Unwrap ¶
func (r Result[T]) Unwrap() T
Unwrap returns the value or panics if error.
Notes:
Panics if the result is an error.
func (Result[T]) UnwrapOr ¶
func (r Result[T]) UnwrapOr(defaultValue T) T
UnwrapOr returns the value or the provided default.
func (Result[T]) UnwrapOrElse ¶
UnwrapOrElse returns the value or calls fn to get a default.
Click to show internal directories.
Click to hide internal directories.