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

Simplify parameter bindings #2359

Closed
wants to merge 9 commits into from
Closed

Simplify parameter bindings #2359

wants to merge 9 commits into from

Conversation

kennykerr
Copy link
Collaborator

This update builds on #2343 and dramatically simplifies input parameter bindings, somethings that's always been rather complicated as we've attempted to model convertibility in Rust. Rather than depend on thousands of From and TryFrom implementations, types now implement the marker traits called CanInto and CanTryInto that do nothing but indicate to the windows crate that such types are convertible. The various Windows APIs can then rely on these traits to transform input arguments in the most efficient way possible, either casting directly to a parent interface (in a COM hierarchy) or calling QueryInterface when a conversion is expected (in a WinRT hierarchy).

The end result is a simpler abstraction with far less code. Specifically, it avoids generating around 7,000 From and TryFrom implementations. That amounts to a lot of functions that the Rust compiler doesn't have to parse, saving on build time.

@kennykerr kennykerr closed this Mar 2, 2023
@kennykerr
Copy link
Collaborator Author

kennykerr commented Mar 2, 2023

Forgot to merge - here's the new PR: #2360

@kennykerr kennykerr deleted the can branch March 3, 2023 20:43
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