-
Notifications
You must be signed in to change notification settings - Fork 390
Open
Description
If I understand correctly, there is currently no way to create UniquePtr<CxxString> on the Rust side without writing own utility function:
unsafe extern "C++" {
fn make_unique_cxx_string(slice: &[u8]) -> UniquePtr<CxxString>;
}std::unique_ptr<std::string> make_unique_cxx_string(rust::Slice<const uint8_t> slice) {
return std::make_unique<std::string>(reinterpret_cast<const char*>(slice.data()), slice.size());
}This is unlike Pin<&mut CxxString> (and consequently &CxxString), which can be made with let_cxx_string!() provided by this library.
Wouldn't it make sense to have a "standard" implementation of make_unique_cxx_string() provided by cxx? It could also be in some more convenient form, for example:
fn make_unique_cxx_string(data: impl AsRef<[u8]>) -> UniquePtr<CxxString>This problem was also mentioned in #1339.
Metadata
Metadata
Assignees
Labels
No labels