Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement AsRawFd/IntoRawFd for RawFd #43254
Comments
Susurrus
referenced this issue
Jul 15, 2017
Open
Replace `RawFd` with `IntoRawFd` or `AsRawFd` as appropriate #678
Mark-Simulacrum
added
the
T-libs
label
Jul 19, 2017
jmesmon
referenced this issue
Jul 24, 2017
Closed
Implement AsRawFd for Stdin, Stdout, Stderr, and RawFd #2074
Mark-Simulacrum
added
the
C-feature-request
label
Jul 28, 2017
This comment has been minimized.
This comment has been minimized.
dtolnay
added
the
rust-2-breakage-wishlist
label
Nov 18, 2017
dtolnay
closed this
Nov 18, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Susurrus commentedJul 15, 2017
•
edited by dtolnay
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
nixto provide good ergonomics. Right nownixoffers a few type wrappers and we implement these traits for it. But we cannot write out functions likeclose<T: IntoRawFd>(fd: T)because while it would work for our wrapped types, it wouldn't work for the plainRawFdtype. We could write a newtype withinnixto wrapRawFdand implement things this way, but it kind of tears theRawFdecosystem 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.