dtolnay/cxx

Support member typedefs (nested types)

Aberta

#593 aberto em 23 de dez. de 2020

 (0 comentário) (1 reação) (0 responsável)Rust (253 forks)batch import
help wanted

Métricas do repositório

Stars
 (4.472 estrelas)
Métricas de merge de PR
 (Mesclagem média 8m) (3 fundiu PRs em 30d)

Description

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

Guia do colaborador