containers v0.3.2 Containers.Result
This container is useful when you want to do chainable maps or sequences on the :ok
:error
tuple
pattern that Elixir uses for actions that could fail.
Implemented Protocols
- Mappable
- Sequenceable
- Unwrappable
Summary
Functions
Takes a normal tuple of either {:ok, value}
or {:error, value}
and
turns it into the Result Container
Types
A tuple that follows the {:ok, value}
or {:error, value}
pattern
Functions
Takes a normal tuple of either {:ok, value}
or {:error, value}
and
turns it into the Result Container.
Will throw NoMatch
error if something other then result_tuple
is
passed in.
Examples
iex> Containers.Result.from_tuple({:ok, "hello"})
%Containers.Result{value: {:ok, "hello"}}
iex> Containers.Result.from_tuple({:error, "no"})
%Containers.Result{value: {:error, "no"}}