Rustic.Result (Rustic.Result v0.2.0) View Source

Documentation for RusticResult.

Link to this section Summary

Types

Describe an Err value

f()

A function that maps a value to a result

Describe an Ok value

t()

Describe a Result type

Functions

Apply a function which returns a result to an Ok result, or propagates the error.

Wraps a value into an Err result

Returns true if the Result is an Err value

Returns true if the Result is an Ok value

Wraps a value into an Ok result

Apply a function which returns a result to an Err result, or propagates the Ok value.

Unwrap an Ok result, or raise an exception

Unwrap an Err result, or raise an exception

Unwrap an Ok result, or return a default value

Link to this section Types

Specs

err() :: {:error, term()}

Describe an Err value

Specs

f() :: (any() -> t())

A function that maps a value to a result

Specs

ok() :: {:ok, any()}

Describe an Ok value

Specs

t() :: ok() | err()

Describe a Result type

Link to this section Functions

Specs

and_then(t(), f()) :: t()

Apply a function which returns a result to an Ok result, or propagates the error.

Specs

err(term()) :: err()

Wraps a value into an Err result

Specs

is_err?(t()) :: boolean()

Returns true if the Result is an Err value

Specs

is_ok?(t()) :: boolean()

Returns true if the Result is an Ok value

Specs

ok(any()) :: ok()

Wraps a value into an Ok result

Specs

or_else(t(), f()) :: t()

Apply a function which returns a result to an Err result, or propagates the Ok value.

Specs

unwrap!(t()) :: any()

Unwrap an Ok result, or raise an exception

Specs

unwrap_err!(t()) :: term()

Unwrap an Err result, or raise an exception

Specs

unwrap_or(t(), any()) :: any()

Unwrap an Ok result, or return a default value