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 rustup
brew install rustup
rustup-init
mix new nif_starter
add {:rustler, "~> 0.22.2"}
mix deps.get
mix rustler new
Module Name > NifStarter
Library name > nif_starter
If 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 build
iex -S mix
NifStarter.add(1, 2)