Utilities for working with strings.
Summary
Functions
Returns true if the node represents a literal string, false otherwise.
Updates a node representing a string with the result of the given function.
Functions
@spec string?(Capstone.Vendor.Sourceror.Zipper.t()) :: boolean()
Returns true if the node represents a literal string, false otherwise.
Examples
iex> zipper = Capstone.Vendor.Sourceror.parse_string!("\"hello\"") |> Capstone.Vendor.Sourceror.Zipper.zip()
iex> Capstone.Vendor.Sourceror.Code.String.string?(zipper)
true
iex> zipper = Capstone.Vendor.Sourceror.parse_string!("123") |> Capstone.Vendor.Sourceror.Zipper.zip()
iex> Capstone.Vendor.Sourceror.Code.String.string?(zipper)
falseSee also update_string/2.
@spec update_string(Capstone.Vendor.Sourceror.Zipper.t(), (String.t() -> {:ok, String.t()} | :error)) :: {:ok, Capstone.Vendor.Sourceror.Zipper.t()} | :error
Updates a node representing a string with the result of the given function.
Examples
iex> zipper = Capstone.Vendor.Sourceror.parse_string!("\"hello\"") |> Capstone.Vendor.Sourceror.Zipper.zip()
iex> {:ok, zipper} = Capstone.Vendor.Sourceror.Code.String.update_string(zipper, fn str -> {:ok, str <> " world"} end)
iex> Capstone.Vendor.Sourceror.to_string(zipper.node)
"\"hello world\""See also string?/1.