Skip to content

Change NonNull::{as_ref, as_mut} to take self rather than &self in a future edition #142947

Open
@tgross35

Description

@tgross35

NonNull has two methods that take &self even though the type is Copy:

The raw pointer methods take self so it is surprising NonNull is different. Taking a reference is unnecessary here and the returned lifetime is unrelated to it.

If we ever get a good way to give methods edition-dependent signatures, this may be something worth considering. Inspired by @cuviper's comment at https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Completing.20our.20set.20of.20pointer-conversion.20methods/near/423274344

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-maybe-future-editionSomething we may consider for a future edition.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