Skip to content

Commit d83fdc1

Browse files
committed
Allow both strings and atoms for crate name
1 parent ac87c7d commit d83fdc1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

rustler_mix/lib/rustler/compiler.ex

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ defmodule Rustler.Compiler do
88
def compile_crate(module, opts) do
99
shell = Mix.shell()
1010
otp_app = Keyword.fetch!(opts, :otp_app)
11-
crate = Atom.to_string(Keyword.fetch!(opts, :crate))
11+
12+
crate = ensure_string(Keyword.fetch!(opts, :crate))
1213
config = Config.from(otp_app, module, opts)
1314

1415
artifacts = Server.build()
@@ -43,4 +44,16 @@ defmodule Rustler.Compiler do
4344

4445
"crates/#{entry[:name]}/#{entry[:version]}/#{type}"
4546
end
47+
48+
defp ensure_string(atom) when is_atom(atom) do
49+
Atom.to_string(atom)
50+
end
51+
52+
defp ensure_string(list) when is_list(list) do
53+
IO.iodata_to_binary(list)
54+
end
55+
56+
defp ensure_string(str) when is_binary(str) do
57+
str
58+
end
4659
end

0 commit comments

Comments
 (0)