The whole point of UWP was to improve COM to make it even better for language interop, increasing the kind of language features that can get exposed as COM libraries.
Also the number one reason that if Rust wants to succeed as system language on Windows it needs to have first class support for COM/UWP.
Just make Rust use the C++ ABI.
C++ code is compiled in separate translation units as C++ by the C++ compiler. The linker statically links calls to C++ code from object files created by the C++ compiler. That's it. Rust doesn't need to know how to deal with templates because templates are all instantiated by the time this happens. This means you have to write a lot of your fancy C++ logic in separate C++ source files (not headers), but that's the whole point, to use already written code.
The only thing Rust has to do is pass pointers to static code and follow the calling and name mangling convention. Zero calling overhead.
However, it would also be extremely hard; I don't think any programming language has ever created such a tight bridge to C++. The existing approaches I've seen are:
- Swig, rust-bindgen, etc.: Pass through auto-generated C ABI wrappers; support for generics is limited and requires declaring up front what types you want to instantiate them with.
- D: You can bind directly to C++ if you rewrite your C++ header in D, generics and all... including the implementations of all inline functions.
Both very limited, especially in template-happy modern C++.