- Connect standard library derives on shared types to C++ operator overloads (#518, #519, #520, #521, #522)
derive(PartialEq)
on the Rust side turns into C++operator==
andoperator!=
derive(PartialOrd)
turns intooperator<
,operator<=
,operator>
,operator>=
derive(Hash)
turns into a specialization oftemplate <> struct std::hash<T>
#[cxx::bridge]
mod ffi {
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
struct AllTheDerives {
x: i32,
y: i32,
}
}
// generated
struct AllTheDerives final {
int32_t x;
int32_t y;
bool operator==(const AllTheDerives &) const noexcept;
bool operator!=(const AllTheDerives &) const noexcept;
bool operator<(const AllTheDerives &) const noexcept;
bool operator<=(const AllTheDerives &) const noexcept;
bool operator>(const AllTheDerives &) const noexcept;
bool operator>=(const AllTheDerives &) const noexcept;
};
namespace std {
template <> struct hash<AllTheDerives> {
size_t operator()(const AllTheDerives &self) const noexcept;
};
}