dtolnay/cxx

Support member typedefs (nested types)

开放

#593 创建于 2020年12月23日

 (0 条评论) (1 个反应) (0 位负责人)Rust (253 个派生)batch import
help wanted

仓库指标

星标
 (4,472 个星标)
PR 合并指标
 (平均合并 8分钟) (30 天内合并 3 个 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;
    }
}

贡献者指南