Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result[T, E any] struct { // contains filtered or unexported fields }
Result represents the result of an operation that is successful or not.
func (Result[T, E]) Err ¶
func (r Result[T, E]) Err() E
Err returns the error of the result. To be used after calling IsOK()
func (Result[T, E]) Unwrap ¶
func (r Result[T, E]) Unwrap() T
Unwrap returns the values of the result. It panics if there is no result due to not checking for errors.
func (Result[T, E]) UnwrapOr ¶ added in v5.22.0
func (r Result[T, E]) UnwrapOr(value T) T
UnwrapOr returns the contained Ok value or a provided default.
Arguments passed to UnwrapOr are eagerly evaluated; if you are passing the result of a function call, look to use `UnwrapOrElse`, which can be lazily evaluated.
func (Result[T, E]) UnwrapOrDefault ¶ added in v5.22.0
func (r Result[T, E]) UnwrapOrDefault() T
UnwrapOrDefault returns the contained Ok value or the default value of the type T.
func (Result[T, E]) UnwrapOrElse ¶ added in v5.22.0
func (r Result[T, E]) UnwrapOrElse(fn func() T) T
UnwrapOrElse returns the contained Ok value or computes it from a provided function.