-
Enable C++ to reserve and read capacity on a
rust::String
(#924) -
Enable Rust to reserve capacity on a
CxxString
(#925)This is important in APIs that connect
bytes
-based code in Rust tostd::string
-based code in C++.use bytes::Buf; use cxx::let_cxx_string; fn thing(buf: &mut dyn Buf) { let_cxx_string!(string = ""); // handled by helper: string.as_mut().reserve(buf.remaining()); while buf.remaining() > 0 { let chunk = buf.chunk(); string.as_mut().push_bytes(chunk); buf.advance(chunk.len()); } ffi::thing(string); } // ffi::thing: // void thing(std::string& s) { // WriteMessage msg{std::move(s)}; // ... // }