Example application for implementing Rust NIFs in Elixir using the Elixir Rustler library with tweaks for Apple Silicon.
These are installation instructions for Mac OS, including some tweaks to get this to work on Apple Silicon using Homebrew.
brew install rustupbrew install rustup
rustup-initmix new nif_starter
add {:rustler, "~> 0.22.2"}
mix deps.getmix rustler new
Module Name > NifStarter
Library name > nif_starterIf you are using Apple Silicon you will need to update the .cargo/config file to build the Rust package
[target.'cfg(target_os = "macos")']
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]cargo buildiex -S mix
NifStarter.add(1, 2)