Using Rust code in D should be relatively easy: expose C API, compile it into a shared library and use it on the D side as any other library. cbindgen (https://github.com/eqrion/cbindgen) can help with generation of header files. Static linking is possible as well.
Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...
> Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...
Can you elaborate? Saying it will be "much more painful" without anything further is not especially helpful. I've added D functions to C programs more or less trivially, including compiling to a shared library, with no change to the code.
Because I am not knowledgeable about D runtime I can not say that it will not cause any conflicts with Rust assumptions (thus the use of "probably"). For example, IIRC there are serious issues with integrating Go code into a Rust project. If D code is compiled in the betterC mode, then there should not be any problems.
There are serious considerations for including Go code in a rust project, but it's not like there are any showstoppers - one just can't use the default runtime and must rely on Cgo, and the FFI entry points are not performant. Other than that, it's relatively painless. Far less painful than calling into the JVM IMO.
You can link in and interop fine with C/C++ as long as you link in the D runtime, kind of how you can mix C and C++ by linking in libcxx.
D's betterC mode ensures that the binary can run purely on libc without D's runtime library. It's kind of like being able to link and execute C++ code without needing libcxx.
Rust is pretty clearly the ascendant language in this (big) niche.
I forecast that as it’s pragmatic, industrial uses (inevitably) grow sharply, that the FFI story will just have to improve. Rust is going to be the next “low-level” language.
The “Pure Rust” talking point will have to recede a bit but it will be a net win for Rust’s truly broad adoption, which is going to happen whether cranky old-timers like me like it or not :)