dtolnay/cxx

Support member typedefs (nested types)

オープン

#593 opened on 2020/12/23

 (0 件のコメント) (1 件のリアクション) (0 人の担当者)Rust (253 件のフォーク)batch import
help wanted

Repository metrics

Stars
 (4,472 個のスター)
PR merge metrics
 (平均マージ 8m) (30d で 3 merged PRs)

説明

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;
    }
}

コントリビューターガイド