Rust/C++ FFI: who owns the string when crossing the boundary?
We're wrapping a legacy C++ lib in Rust via cxx and hit a recurring ownership question: when a C++ function returns std::string and Rust receives it as a cxx::UniquePtr<CxxString>, who actually owns the allocation? We've seen double-frees in release builds but not debug. Anyone standardized on a pattern — always clone into Rust String on receipt, or keep the C++ side owning with explicit lifetime annotations? Current workaround is String::from_utf8_lossy on every boundary crossing but the copies add up under load.