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 · 1 comment

Comments

Projects
None yet
3 participants
@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.

@dtolnay

This comment has been minimized.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.