cxx
cxx copied to clipboard
CxxVector::new / CxxVector::with_capacity
Thanks for adding CxxVector::push/pop in https://github.com/dtolnay/cxx/issues/778. To remove the other most common kind of manual binding work when working with CxxVector, a CxxVector::new and a CxxVector::with_capacity function would be great. A (for me) common pattern is to call a C++ function from rust and passing it a CxxVector of C++ objects (say CxxVector<SharedPtr>). With CxxVector::new/with_capacity, I could create the CxxVector and add all the SharedPtr to it entirely on the Rust side without having to go through manual ffi bindings.
Hm yeah this one is a little odd omission. I have lots of C++ APIs that accept std::vector of various types, and it's unclear how to create those from Rust in the current model.
Ah... wait, I can't even create bindings for APIs that accept std::vector<CustomType>. In that case creation is a smaller problem.