alef 0.34.5

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
  @doc "Unregister a previously registered {{ trait_name }} plugin by name."
  @spec {{ func_name }}(String.t() | keyword(String.t())) :: :ok | :error
  def {{ func_name }}(name_or_opts) do
    name = case name_or_opts do
      # Positional form: unregister_fn("name")
      n when is_binary(n) -> n
      # Keyword-list form from Elixir: unregister_fn([{:name, "name"}])
      # This happens when tests use `unregister_fn(name: "value")` with force_keyword_args
      opts when is_list(opts) -> Keyword.get(opts, :name, "")
      _ -> ""
    end
    {{ native_mod }}.{{ func_name }}(name)
  end