github dtolnay/cxx 1.0.6

latest releases: 1.0.129, 1.0.128, 1.0.127...
3 years ago
  • 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;
  };
}

Don't miss a new cxx release

NewReleases is sending notifications on new releases.