Skip to content

Simplify parameter bindings#2359

Closed
kennykerr wants to merge 9 commits intomasterfrom
can
Closed

Simplify parameter bindings#2359
kennykerr wants to merge 9 commits intomasterfrom
can

Conversation

@kennykerr
Copy link
Copy Markdown
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
Copy Markdown
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