Implement AsRawFd/IntoRawFd for RawFd #43254
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.
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 nownix
offers 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 plainRawFd
type. We could write a newtype withinnix
to wrapRawFd
and implement things this way, but it kind of tears theRawFd
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.The text was updated successfully, but these errors were encountered: