want v1.1.1 Want.Atom

Performs type conversions to atom values.

Link to this section Summary

Functions

Cast a value to an atom.

Callback implementation for Want.Type.cast/2.

Link to this section Types

Link to this type

result()

result() :: {:ok, atom()} | {:error, binary()}

Link to this section Functions

Link to this function

cast(value)

cast(value :: any()) :: result()

Cast a value to an atom.

Options

  • :exists - If true, only convert to an atom if a matching atom already exists.

Examples

iex> Want.Atom.cast("hello")

iex> Want.Atom.cast(1.0)

iex> Want.Atom.cast({:a, :b}) {:error, "Failed to convert value {:a, :b} to atom."}

iex> Want.Atom.cast("10", exists: true)

Link to this function

cast(value, opts)

cast(value :: any(), opts :: Keyword.t()) :: result()

Callback implementation for Want.Type.cast/2.