Skip to content

Document pointer cast safety in std::path #45910

Description

@udoprog

Hey,

I'm curious about the unsafe cast in Path.

From what I understand: this works because Path is a single member struct containing only the type it's being reinterpreted as.

My original question on #rust IRC was: Is this always guaranteed to be correct (in Rust) in terms of memory layout?

The discussion seemed to hint at that this is in fact not a guarantee, but that std is in a unique position being developed in concert with the language and any future breakage would be patched when it occurs.

I would love some clarification if this usage is correct or to what degree it is not. I'd also suggest we add clarification around this case with comments or support functions to aid future spelunking into std.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-acceptedCategory: A feature request that has been accepted pending implementation.T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions