I’m doing some Rust FFI work for the Erlang NIF API, and I have these:
ErlNifEnv *enif_alloc_env();
void enif_free_env(ErlNifEnv* env);
This ErlNifEnv pointer gets passed to a variety of other functions but the user will never deref the pointer. Also, this pointer is not threadsafe (use amongst multiple threads would require a mutex). The naive Rust representation of this type would be..
struct ErlNifEnv;
*mut ErlNifEnv;
But, I think I can treat this type as having “interior mutability” which would lead to…
struct ErlNifEnv;
*const ErlNifEnv;
Should I be treating this pointer as const even though the underlying C code sees it as non-const?