Skip to content

Confusing MaybeUninit documentation #65216

Open
@DutchGhost

Description

@DutchGhost

The as_ptr method on a MaybeUninit<T> perhaps could use some better wording, or at least an example.

The docs say: "Writing to memory that this pointer (non-transitively) points to is undefined behavior (except inside an UnsafeCell)."

Its unclear whether that means &MaybeUninit<UnsafeCell<T>> -> *const UnsafeCell<T> -> *mut T is okey, or that &UnsafeCell<MaybeUninit<T>> -> *mut MaybeUninit<T> -> *mut T is okey, if the resulting mutable pointer is written to.

Perhaps adding a little example of which of the two is okey, (or perhaps both) would help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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