Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: ensure that extern "Rust" methods on C++ types work #1233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ahayzen-kdab
Copy link
Contributor

This allows for developers and crates that are generating both C++ and Rust code to have a C++ method implemented in Rust without having to use a free method and passing through the C++ "this" as an argument.

This allows for developers and crates that are generating both C++ and Rust
code to have a C++ method implemented in Rust without having to use a
free method and passing through the C++ "this" as an argument.
@ahayzen-kdab
Copy link
Contributor Author

While trying to simplify our free functions and wrapper methods going between generated C++ classes, Rust structs, and methods implemented in a C++ context in Rust. We found that it was possible to implement a Rust method onto a C++ type. As CXX only generates the implementation for it and we are generating the C++ class we can specify the right header match. Then this avoids us having to have a free function to proxy C++ calls to the Rust calls as we can then go directly between.

As this was slightly non-obvious we wanted to submit a test to ensure that the behaviour doesn't regress and to ensure that it is accepted behaviour that we can depend on.

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.

None yet

1 participant