ret

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And[T any, U any](r gust.Result[T], r2 gust.Result[U]) gust.Result[U]

And returns r2 if the result is Ok, otherwise returns the error of r.

func AndThen

func AndThen[T any, U any](r gust.Result[T], op func(T) gust.Result[U]) gust.Result[U]

AndThen calls op if the result is Ok, otherwise returns the error of self. This function can be used for control flow based on gust.Result values.

func Assert added in v0.7.0

func Assert[T any, U any](o gust.Result[T]) gust.Result[U]

Assert asserts gust.Result[T] as gust.Result[U].

func Contains

func Contains[T comparable](r gust.Result[T], x T) bool

Contains returns true if the result is an Ok value containing the given value.

func EnumAnd added in v0.7.0

func EnumAnd[T any, U any, E any](a gust.EnumResult[T, E], b gust.EnumResult[U, E]) gust.EnumResult[U, E]

EnumAnd returns `b` if the `a` is Ok, otherwise returns the error of `a`.

func EnumAndThen added in v0.7.0

func EnumAndThen[T any, U any, E any](r gust.EnumResult[T, E], op func(T) gust.EnumResult[U, E]) gust.EnumResult[U, E]

EnumAndThen calls op if the result is Ok, otherwise returns the error of self. This function can be used for control flow based on gust.EnumResult values.

func EnumAssert added in v0.7.0

func EnumAssert[T any, E any, U any, F any](o gust.EnumResult[T, E]) gust.EnumResult[U, F]

EnumAssert asserts gust.EnumResult[T,E] as gust.EnumResult[U,F].

func EnumFlatten added in v0.7.0

func EnumFlatten[T any, E any](r gust.EnumResult[gust.EnumResult[T, E], E]) gust.EnumResult[T, E]

EnumFlatten converts from gust.EnumResult[gust.EnumResult[T,E]] to gust.EnumResult[T,E].

func EnumMap added in v0.7.0

func EnumMap[T any, U any, E any](r gust.EnumResult[T, E], f func(T) U) gust.EnumResult[U, E]

EnumMap maps a gust.EnumResult[T,E] to gust.EnumResult[U,E] by applying a function to a contained Ok value, leaving an error untouched. This function can be used to compose the results of two functions.

func EnumMapErr added in v0.7.0

func EnumMapErr[T any, E any, F any](r gust.EnumResult[T, E], op func(E) F) gust.EnumResult[T, F]

EnumMapErr maps a EnumResult[T,E] to EnumResult[T,F] by applying a function to a contained E, leaving an T value untouched. This function can be used to pass through a successful result while handling an error.

func EnumMapOr added in v0.7.0

func EnumMapOr[T any, U any, E any](r gust.EnumResult[T, E], defaultOk U, f func(T) U) U

EnumMapOr returns the provided default (if error), or applies a function to the contained value (if no error), Arguments passed to map_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use MapOrElse, which is lazily evaluated.

func EnumMapOrElse added in v0.7.0

func EnumMapOrElse[T any, U any, E any](r gust.EnumResult[T, E], defaultFn func(E) U, f func(T) U) U

EnumMapOrElse maps a gust.EnumResult[T,E] to U by applying fallback function default to a contained error, or function f to a contained Ok value. This function can be used to unpack a successful result while handling an error.

func EnumOr added in v0.7.0

func EnumOr[T any, E any, F any](a gust.EnumResult[T, E], b gust.EnumResult[T, F]) gust.EnumResult[T, F]

EnumOr returns `b` if `a` is E, otherwise returns the T value of `a`. Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use EnumOrElse, which is lazily evaluated.

func EnumOrElse added in v0.7.0

func EnumOrElse[T any, E any, F any](result gust.EnumResult[T, E], op func(E) gust.EnumResult[T, F]) gust.EnumResult[T, F]

EnumOrElse calls op if the result is E, otherwise returns the T value of result. This function can be used for control flow based on result values.

func EnumXAssert added in v0.7.0

func EnumXAssert[T any, E any](o gust.EnumResult[any, any]) gust.EnumResult[T, E]

EnumXAssert asserts gust.EnumResult[any, any] as gust.EnumResult[T, E].

func EnumXErrAssert added in v0.7.0

func EnumXErrAssert[T any, E any](o gust.EnumResult[T, any]) gust.EnumResult[T, E]

EnumXErrAssert asserts gust.EnumResult[T, any] as gust.EnumResult[T, E].

func EnumXOkAssert added in v0.7.0

func EnumXOkAssert[T any, E any, U any](o gust.EnumResult[any, E]) gust.EnumResult[U, E]

EnumXOkAssert asserts gust.EnumResult[any, E] as gust.EnumResult[U, E].

func Flatten

func Flatten[T any](r gust.Result[gust.Result[T]]) gust.Result[T]

Flatten converts from gust.Result[gust.Result[T]] to gust.Result[T].

func Map

func Map[T any, U any](r gust.Result[T], f func(T) U) gust.Result[U]

Map maps a gust.Result[T] to gust.Result[U] by applying a function to a contained Ok value, leaving an error untouched. This function can be used to compose the results of two functions.

func MapOr

func MapOr[T any, U any](r gust.Result[T], defaultOk U, f func(T) U) U

MapOr returns the provided default (if error), or applies a function to the contained value (if no error), Arguments passed to map_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use MapOrElse, which is lazily evaluated.

func MapOrElse

func MapOrElse[T any, U any](r gust.Result[T], defaultFn func(error) U, f func(T) U) U

MapOrElse maps a gust.Result[T] to U by applying fallback function default to a contained error, or function f to a contained Ok value. This function can be used to unpack a successful result while handling an error.

func XAssert added in v0.7.0

func XAssert[U any](o gust.Result[any]) gust.Result[U]

XAssert asserts gust.Result[any] as gust.Result[U].

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL