Skip to content

Implement AsRawFd/IntoRawFd for RawFd #43254

Closed
@Susurrus

Description

@Susurrus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions