OkThen.Result.tagged_retag
You're seeing just the function
tagged_retag
, go back to OkThen.Result module for more information.
Link to this function
tagged_retag(result, tag, new_tag)
Specs
tagged_retag(result_input(), atom(), new_tag) :: new_tag | {new_tag, any()} when new_tag: atom()
If result
is tagged with the specified tag
atom, replaces the tag with new_tag
, returning
a new tagged tuple.
Examples
iex> :ok |> Result.tagged_retag(:ok, :none)
:none
iex> {:ok, "hello"} |> Result.tagged_retag(:ok, :error)
{:error, "hello"}
iex> {:error, 1, 2} |> Result.tagged_retag(:error, :ok)
{:ok, {1, 2}}
iex> {:ok, 1, 2} |> Result.tagged_retag(:error, :ok)
{:ok, 1, 2}
iex> :ok |> Result.tagged_retag(:ok, "string")
** (ArgumentError) Expected atom as new tag, got: "string".
iex> "bare value" |> Result.tagged_retag(:ok, :error)
"bare value"
iex> "bare value" |> Result.tagged_retag(:untagged, :error)
{:error, "bare value"}