dtolnay / cxx

Safe interop between Rust and C++
https://cxx.rs
Apache License 2.0
5.82k stars 330 forks source link

Implement TryInto<String> for &CxxString #1316

Closed tolvanea closed 7 months ago

tolvanea commented 7 months ago

Added standard conversion Trait from CxxString to rust String. It is implemented only for reference of CxxString, because CxxString does usually exists in owned form on rust side .

tolvanea commented 7 months ago

The idea was to make conversion between CxxString and rust String more fluent with only one call cxxstr.try_into()?. But now that I think this again, it is too far fetch to bake two distinct conversion steps (cxx->rust and reference->owned) into one. Also, apparently std::ffi::CString does not even implement TryInto<String>, so not seeing a need for this either.

My apologies, it felt so natural at the time. Closing this.