Add expose_provenance and from_exposed_provenance on NonNull · Issue #518 · rust-lang/libs-team (original) (raw)

Proposal

Problem statement

expose_provenance and from_exposed_provenance exist on raw pointers but not on NonNull.

Motivating examples or use cases

This seems like a simple oversight; to my knowledge we generally aim for API consistency between NonNull and raw pointers.

Solution sketch

impl NonNull { pub fn expose_provenance(self) -> NonZero; pub fn from_exposed_provenance(addr: NonZero) -> Self; }

Alternatives

We could do nothing.

What happens now?

This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.

Possible responses

The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):

Second, if there's a concrete solution: