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

Trait method std::os::windows::fs::OpenOptionsExt::security_qos_flags() returns a &mut OpenOptions instead of &mut Self #49961

Closed
Ereski opened this issue Apr 14, 2018 · 4 comments
Labels
O-windows Operating system: Windows T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Ereski
Copy link

Ereski commented Apr 14, 2018

https://doc.rust-lang.org/src/std/sys/windows/ext/fs.rs.html#279-281

There's no reason for that method to return a concrete type instead of Self. I am currently writing an OpenOptions wrapper and that method is preventing me from implementing OpenOptionsExt for the wrapper. However, the trait is already stable (even if most likely unimplemented outside libstd) so I'm not sure what's the proper way of changing this?

bors added a commit that referenced this issue Apr 14, 2018
change OpenOptions to Self in std::os::windows::fs

Fixes #49961
@retep998 retep998 added O-windows Operating system: Windows T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Apr 14, 2018
@alexcrichton
Copy link
Member

Thanks for the report @Ereski! Unfortunately though it's very much not the intention of these extension traits to be implemented for foreign types. We added the extension traits to libstd with the intent to eventually add more methods over time as they came up, but we then forgot to add protections to make sure they weren't implemented externally! (our mistake)

In the meantime though I'd recommend either defining inherent methods and/or defining your own extension trait.

@Ereski
Copy link
Author

Ereski commented Apr 19, 2018

@alexcrichton I see. However in this case (and a few others), the fact that they can't be implemented by external types means wrapper types can't act as drop-in replacements for libstd types in all cases, which is my intent.

Just to clarify, all extensions traits (TypeExt for some type?) are considered unstable to implement and stable to use?

@alexcrichton
Copy link
Member

@Ereski yeah at this time the *Ext traits are intended to be internal implementation details of libstd (purely intended as a trait for one particular type).

@retep998
Copy link
Member

I believe the current goal is to replace the extension traits with inherent methods directly on the types, but with the portability lint so you're still aware you're using platform specific methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants