For writing rust libraries wrapping C++ libraries where the C++ API makes heavy use of templated types, the current cxx.rs implementation needs you to create an opaque type and function for each template instantiation. It would be nice if we could build direct bindings for the template instead:
// C++
template<class T> std::unique_ptr<APIObject<T>> method();
// Rust
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
type APIObject<T>;
fn method<T>() -> UniquePtr<APIObject<T>>;
}
}
I think this would hugely simplify writing rust wrappers for existing C++ libraries.
For writing rust libraries wrapping C++ libraries where the C++ API makes heavy use of templated types, the current cxx.rs implementation needs you to create an opaque type and function for each template instantiation. It would be nice if we could build direct bindings for the template instead:
I think this would hugely simplify writing rust wrappers for existing C++ libraries.