1

What is the workflow for implementing ERTS NIFs in Zig?

Is there something comparable to Rustler for NIFs authored in Rust?

Max Heiber
  • 14,346
  • 12
  • 59
  • 97
  • Zigler? https://hexdocs.pm/zigler/Zigler.html . There was also a talk about it on zig showtime: https://www.youtube.com/watch?v=fIxNEILcNGM – pfg Sep 18 '20 at 05:53
  • awesome! If you post this as an answer I'll mark it correct so it's easy for people to find. – Max Heiber Sep 18 '20 at 21:12

1 Answers1

1

The Zigler package can be used: https://github.com/ityonemo/zigler, https://hex.pm/packages/zigler

defmodule ExampleZig do
  use Zig
  ~Z"""
  /// nif: example_fun/2
  fn example_fun(value1: f64, value2: f64) bool {
    return value1 > value2;
  }
  """
end

test "example nifs" do
  assert ExampleZig.example_fun(0.8, -0.8)
  refute ExampleZig.example_fun(0.1, 0.4)
end
pfg
  • 2,348
  • 1
  • 16
  • 37