-
Notifications
You must be signed in to change notification settings - Fork 387
Description
Hello,
Thank you for all the work on the cxx crate. I am sorry for a not very specific nor constructive issue, but I was wondering what it would take to decouple individual type mappings (e.g. std::vector<T> to CxxVector<T>, std::map<K, V> to TBD<K, V>, etc.) from the cxx crate itself. In particular, some projects have their own container implementations (e.g. Boost''s flat_map or Chromium's small_map or WebKit's WTF::Vector) or string implementations (e.g. WebKit's 16-bit String). It would be great if such projects could extend cxx with the extra mappings, without having to modify the cxx crate itself. AFAIU cxx already supports translating std::string and std::vector and plans to support std::map and std::unordered_map, but obviously would probably dislike having knowledge of Boost's, Chromium's or WebKit's types.
Could you please offer any feedback / thoughts on the above?
-
It is unclear to me how one would declare that a given C++ type should be recognized and wrapped in a specific way in Rust. Specifying the C++ type via its namespace-qualified name is definitely one possible way, but maybe some form of duck-typing is also desirable (handwaving: if a C++ type has
beginandendmethods, then it is wrapped asstd::iter::Iteratoror asIntoIterator; if it quacks like a drop-in replacement for std::map, then it is wrapped asCxxMap; etc); -
It is unclear to me exactly which C++ => Rust type mappings would need to remain in the core
cxx(even if they don't need to be incxxand could be decoupled for design/hygiene reasons, we might still want to keep all thestdlibrary types close tocxx, to promote one canonicalstd=> Rust type mapping).- I guess
UniquePtrwould remain in the core. - I am not sure about
CxxStringandCxxVector.
- I guess
-
It is unclear to me how extensible type mappings impact with the safety guarantees of
cxxand Rust.
/cc @adetaylor