You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to construct CxxString on the Rust side and return it to the C++ side?
Returning Pin<&mut CxxString> doesn't work, because it's just a reference to local variable, which is destroyed at the end of the function:
fnhello<'a>() -> std::pin::Pin<&'a mutCxxString>{let_cxx_string!(name = "Hello from Rust string!");
name // ERROR: returns a value referencing data owned by the current function}
Returning UniquePtr<CxxString> doesn't work, because I'm not able to construct it:
fnhello2<'a>() -> cxx::UniquePtr<CxxString>{let_cxx_string!(name = "Hello from Rust string!");
cxx::UniquePtr::new(*name)// ERROR: type mismatch resolving `<CxxString as ExternType>::Kind == Trivial`// expected `Trivial`, found `Opaque`}
How can I do it? I want my generated bindings to use standard C++ structs such as std::string without needing the C++ users to deal with rust::String which they might not know and might not work with other C++ libraries.
The text was updated successfully, but these errors were encountered:
In case you're still trying to do this, I wanted to do something similar, but I don't think it's possible. What I ended up doing instead is used an out parameter.
Is it possible to construct
CxxString
on the Rust side and return it to the C++ side?Returning
Pin<&mut CxxString>
doesn't work, because it's just a reference to local variable, which is destroyed at the end of the function:Returning
UniquePtr<CxxString>
doesn't work, because I'm not able to construct it:How can I do it? I want my generated bindings to use standard C++ structs such as
std::string
without needing the C++ users to deal withrust::String
which they might not know and might not work with other C++ libraries.The text was updated successfully, but these errors were encountered: