Documentation
¶
Index ¶
- func And[T any, U any](r gust.Result[T], r2 gust.Result[U]) gust.Result[U]
- func AndThen[T any, U any](r gust.Result[T], op func(T) gust.Result[U]) gust.Result[U]
- func Assert[T any, U any](o gust.Result[T]) gust.Result[U]
- func Contains[T comparable](r gust.Result[T], x T) bool
- func EnumAnd[T any, U any, E any](a gust.EnumResult[T, E], b gust.EnumResult[U, E]) gust.EnumResult[U, E]
- func EnumAndThen[T any, U any, E any](r gust.EnumResult[T, E], op func(T) gust.EnumResult[U, E]) gust.EnumResult[U, E]
- func EnumAssert[T any, E any, U any, F any](o gust.EnumResult[T, E]) gust.EnumResult[U, F]
- func EnumFlatten[T any, E any](r gust.EnumResult[gust.EnumResult[T, E], E]) gust.EnumResult[T, E]
- func EnumMap[T any, U any, E any](r gust.EnumResult[T, E], f func(T) U) gust.EnumResult[U, E]
- func EnumMapErr[T any, E any, F any](r gust.EnumResult[T, E], op func(E) F) gust.EnumResult[T, F]
- func EnumMapOr[T any, U any, E any](r gust.EnumResult[T, E], defaultOk U, f func(T) U) U
- func EnumMapOrElse[T any, U any, E any](r gust.EnumResult[T, E], defaultFn func(E) U, f func(T) U) U
- func EnumOr[T any, E any, F any](a gust.EnumResult[T, E], b gust.EnumResult[T, F]) gust.EnumResult[T, F]
- func EnumOrElse[T any, E any, F any](result gust.EnumResult[T, E], op func(E) gust.EnumResult[T, F]) gust.EnumResult[T, F]
- func EnumXAssert[T any, E any](o gust.EnumResult[any, any]) gust.EnumResult[T, E]
- func EnumXErrAssert[T any, E any](o gust.EnumResult[T, any]) gust.EnumResult[T, E]
- func EnumXOkAssert[T any, E any, U any](o gust.EnumResult[any, E]) gust.EnumResult[U, E]
- func Flatten[T any](r gust.Result[gust.Result[T]]) gust.Result[T]
- func Map[T any, U any](r gust.Result[T], f func(T) U) gust.Result[U]
- func MapOr[T any, U any](r gust.Result[T], defaultOk U, f func(T) U) U
- func MapOrElse[T any, U any](r gust.Result[T], defaultFn func(error) U, f func(T) U) U
- func XAssert[U any](o gust.Result[any]) gust.Result[U]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AndThen ¶
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 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 Map ¶
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 ¶
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.
Types ¶
This section is empty.