Skip to content

Add #[repr(transparent)] to PathBuf #72838

Closed
@jhpratt

Description

@jhpratt

The fact that PathBuf is internally an OsStr is currently noted as an implementation detail in comments. However, a number of methods clearly indicate (in documentation) that it is stored as such, and one PathBuf::into_os_str() implicitly requires it, as it would be inefficient to do it otherwise.

Would it make sense to add #[repr(transparent)] to PathBuf to externally stabilize this guarantee? It would also allow me (as the maintainer of the standback crate) to use transmute in a guaranteed manner.

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