dtolnay/cxx

Support member typedefs (nested types)

開放

#593 建立於 2020年12月23日

 (0 則留言) (1 個反應) (0 位負責人)Rust (253 個分叉)batch import
help wanted

倉庫指標

星標
 (4,472 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

For example the following binding involving https://en.cppreference.com/w/cpp/container/map/at on a std::map:

class json {
public:
  using number = double;
  using string = std::string;
  using array = std::vector<json>;
  using object = std::map<string, json>;
  ...
private:
  std::variant<std::monostate, number, string, array, object> value;
};
#[cxx::bridge]
mod ffi {
    unsafe extern "C++" {
        type json;

        fn at<'a>(self: &'a json::object, key: &CxxString) -> &'a json;
    }
}

Maybe also as:

#[cxx::bridge]
mod ffi {
    unsafe extern "C++" {
        type json;

        #[cxx_name = "json::object"]
        type object;

        fn at<'a>(self: &'a object, key: &CxxString) -> &'a json;
    }
}

貢獻者指南