Skip to content

1.0.6

Choose a tag to compare

@dtolnay dtolnay released this 28 Nov 02:44
· 2854 commits to master since this release
1.0.6
ecce017
  • 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== and operator!=
    • derive(PartialOrd) turns into operator<, operator<=, operator>, operator>=
    • derive(Hash) turns into a specialization of template <> 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;
  };
}