Since you talked about rust in your original post, rustler allows you to write NIFs that can't crash the BEAM, never felt the need to use it, but at least it exists.
I'm totally aware of Rustler :) but it's a nice tool to share! I was mostly trying to speak to the real world environment where you have a simple routine or interface already prepackaged and you want access to it... Not that you can't use Rustler, but just being able to access the C interface directly is comforting (and sometimes easier than adding another compilation step between them even if it is _safer_ (e.g. prototyping)).
https://github.com/rusterlium/rustler