autocxx icon indicating copy to clipboard operation
autocxx copied to clipboard

Make creating `std::vector` on the Rust side possible

Open scentini opened this issue 4 years ago • 1 comments

Supose we have a struct A, and a function void processA(const vector<A> &v).

In Rust we we want to create an A object and call the processA function with it, but this is currently not possible as there is no way to create a cxx::CxxVector from Rust.

If A is a trivial type, we should be able to write a function that will convert between rust::Vec and std::Vector:

std::vector<A> convertToCppVector (rust::Vec<A>) {...}

However autocxx does not currently support rust::Vec.

For non-trivial A this is not possible as Vec<T>does not support T being an opaque C++ type.

scentini avatar Jun 07 '21 12:06 scentini

Manual example, requiring C++ addition. https://github.com/google/autocxx/compare/create-vec in case I decide that we can't make this easier...

adetaylor avatar Jun 22 '21 04:06 adetaylor