Skip to content

Conversation

@copybara-service
Copy link

Refine PartialEq binding generation to support C++ types with only operator!=.

Rust's PartialEq trait requires an eq method. Previously, Crubit could not generate bindings for C++ types that only overloaded operator!=.

This CL addresses this by generating an eq implementation that calls the C++ operator!= thunk and negates its result.

Additionally, when a C++ type overloads both operator== and operator!=, it avoids generating a binding for operator!=. Instead, it relies on the default ne implementation provided by Rust's PartialEq trait, which is more idiomatic and avoids a redundant thunk.

…erator!=.

Rust's PartialEq trait requires an eq method. Previously, Crubit could not generate bindings for C++ types that only overloaded operator!=.

This CL addresses this by generating an eq implementation that calls the C++ operator!= thunk and negates its result.

Additionally, when a C++ type overloads both operator== and operator!=, it avoids generating a binding for operator!=. Instead, it relies on the default ne implementation provided by Rust's PartialEq trait, which is more idiomatic and avoids a redundant thunk.

PiperOrigin-RevId: 831756584
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant