-
Notifications
You must be signed in to change notification settings - Fork 507
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
Feature request: Apply standard Rust naming conventions for types that implement ownership semantics #2126
Comments
I think this has potential but is not very clearcut. Simple examples like |
Hm, true, I hadn't considered generated types... Renaming those is certainly out of the question. Which would leave this feature request scoped to the "support library", i.e. types that live in the While I would personally still prefer having those types follow Rust's naming convention, I will admit that this leaves much of the initial motivation untapped. Maybe a better case for renaming those two types can be made when |
Another reason we don't follow Rust's naming conventions is that it becomes very difficult to find corresponding documentation - switching from the official docs to Rust and back becomes very challenging. For that reason alone, I'd prefer to keep the naming consistent with the Windows SDK. Going back to your original point about the difficulty of distinguishing between types that "do the right thing" and types that expect the caller to "do the right thing", I think we should focus on making more of the types in the |
I don't know how plausible this is in the conventional " For example If |
Motivation
The motivation behind this feature request is to make client code more comprehensible. It's currently difficult to tell ABI(-like) "all-management-on-the-client" types and Rust's "ownership-is-a-solved-problem" types apart.
Since the question recently came up as to what the ownership semantics of the various types of the windows-rs crate are, I'm proposing to encode this information by following standard Rust naming conventions.
The only types affected by this proposal (to my knowledge) are
BSTR
andHSTRING
(to be renamed toBstr
(BStr
?) andHString
, respectively). COM and WinRT interfaces are already following this convention, signaling to clients that ownership is handled.P[C][W]STR
may need to be considered, still.Drawbacks
This is a breaking change. Like any breaking change, it's going to cause noise, downstream.
I believe the perturbations to be manageable. From personal experience, both rustc and clippy do a fabulous job at driving authors to make the right adjustments.
Rationale and alternatives
As an alternative to renaming the types, type aliases could be provided for easier migration. I'm not sure this is strictly necessary pre-v1.0, and type aliases tend to increase complexity.
Additional context
This consideration is certainly going to come up again when support for
VARIANT
s (orSAFEARRAY
s, maybe) is approached. Having distinct casing for the resource management wrappers and raw ABI types makes it easier to tell them apart.The text was updated successfully, but these errors were encountered: