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

Implement AsRawFd/IntoRawFd for RawFd #43254

Closed
Susurrus opened this issue Jul 15, 2017 · 2 comments
Closed

Implement AsRawFd/IntoRawFd for RawFd #43254

Susurrus opened this issue Jul 15, 2017 · 2 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Susurrus
Copy link
Contributor

Susurrus commented Jul 15, 2017

This was originally filed and merged as #40842 and then backed out in #41035 as it was found to be unsound. This, however, would still be very useful in allowing nix to provide good ergonomics. Right now nix offers a few type wrappers and we implement these traits for it. But we cannot write out functions like close<T: IntoRawFd>(fd: T) because while it would work for our wrapped types, it wouldn't work for the plain RawFd type. We could write a newtype within nix to wrap RawFd and implement things this way, but it kind of tears the RawFd ecosystem in half doing that.

I think the only way to do this is to use a newtype instead of a type alias for RawFd. I'm pretty certain, however, that couldn't be done in a backwards-compatible manner, but maybe I'm wrong. Anyways, just wanted to see what the response would be to this and if there might be upcoming Rust features that could make such a solution possible.

@Mark-Simulacrum Mark-Simulacrum added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jul 19, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 28, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 18, 2017

If anyone comes up with a way to solve this without implementing AsRawFd for i32 as happened in #40842, I would be open to considering an RFC. For now tagging with rust-2-breakage-wishlist to reconsider the design of RawFd.

@dtolnay dtolnay added the rust-2-breakage-wishlist In the wishlist of breaking changes that requires rust 2.0 label Nov 18, 2017
@dtolnay dtolnay closed this as completed Nov 18, 2017
@dtolnay
Copy link
Member

dtolnay commented Oct 20, 2023

These implementations got added (again) in #76969.

@dtolnay dtolnay removed the rust-2-breakage-wishlist In the wishlist of breaking changes that requires rust 2.0 label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. 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