Rustic.Result (Rustic.Result v0.6.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.

Iterate over Results, will fail at the first Error result.

Wraps a value into an Err result

Iterate over Results, will ignore failed items.

Flatten a result containing another result.

Returns true if the Result is an Err value

Is valid if and only if an Err result is supplied

Returns true if the Result is an Ok value

Is valid if and only if an Ok result is supplied

Apply a function to the value contained in an Ok result, or propagates the error.

Apply a function to the value contained in an Err result, or propagates the Ok result.

Wraps a value into an Ok result

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

Iterate over Results, returns a tuple of

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 | {: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

collect(Enumerable.t(t())) :: t()

Iterate over Results, will fail at the first Error result.

Specs

err(term()) :: err()

Wraps a value into an Err result

Link to this function

filter_collect(enumerable)

View Source

Specs

filter_collect(Enumerable.t(t())) :: ok()

Iterate over Results, will ignore failed items.

Specs

flatten(t()) :: t()

Flatten a result containing another result.

Specs

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

Returns true if the Result is an Err value

Link to this macro

is_err_result(val)

View Source (macro)

Is valid if and only if an Err result is supplied

Specs

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

Returns true if the Result is an Ok value

Link to this macro

is_ok_result(val)

View Source (macro)

Is valid if and only if an Ok result is supplied

Specs

map(t(), (any() -> any())) :: t()

Apply a function to the value contained in an Ok result, or propagates the error.

Specs

map_err(t(), (any() -> any())) :: t()

Apply a function to the value contained in an Err result, or propagates the Ok result.

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.

Link to this function

partition_collect(enumerable)

View Source

Specs

partition_collect(Enumerable.t(t())) :: {ok(), err()}

Iterate over Results, returns a tuple of:

  • Ok result containing the list of Ok values
  • Err result containing the list of Err reasons

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

Link to this function

unwrap_or(arg1, default)

View Source

Specs

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

Unwrap an Ok result, or return a default value