【问题标题】:What is the workflow for implementing ERTS NIFs in Zig?在 Zig 中实施 ERTS NIF 的工作流程是什么?
【发布时间】:2020-12-29 05:23:39
【问题描述】:

在 Zig 中实现ERTS NIFs 的工作流程是什么?

对于用 Rust 编写的 NIF,是否有与 Rustler 类似的东西?

【问题讨论】:

标签: erlang zig


【解决方案1】:

可以使用Zigler包: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

【讨论】:

    猜你喜欢
    • 2012-12-13
    • 2015-05-23
    • 1970-01-01
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多