Description
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.