Skip to content

Alignment: move from ptr to mem and rename as_nonzero to as_nonzero_usize#154004

Open
GrigorenkoPV wants to merge 2 commits intorust-lang:mainfrom
GrigorenkoPV:alignment/as_nonzero_usize
Open

Alignment: move from ptr to mem and rename as_nonzero to as_nonzero_usize#154004
GrigorenkoPV wants to merge 2 commits intorust-lang:mainfrom
GrigorenkoPV:alignment/as_nonzero_usize

Conversation

@GrigorenkoPV
Copy link
Contributor

@GrigorenkoPV GrigorenkoPV commented Mar 17, 2026

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 17, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet, scottmcm

@bjoernager
Copy link
Contributor

bjoernager commented Mar 19, 2026

Should the identifier not be as_non_zero_usize? The current convention with NonNull, at least, is to use non_null as the snake_case form.

@clarfonthey
Copy link
Contributor

clarfonthey commented Mar 19, 2026

That's an interesting observation, and after looking into precedent… it could be either way. Searching for "non" in the standard library docs: https://doc.rust-lang.org/nightly/std/?search=non

Excluding false positives, we have the following which are stable:

  • std::net::(various)::set_nonblocking
  • (various)::{copy, swap}{, _from, _to}nonoverlapping
  • std::fmt::(various)::finish_non_exhaustive

And the following unstable:

So, really, the answer is that there's not really been a consistent choice, except that non_exhaustive is stable and so is nonblocking and nonoverlapping. The rest are just unstable methods.

In general… we do tend to prefer non_zero over nonzero, but we do have nonblocking and nonoverlapping that probably could be deprecated and renamed, if someone cared enough.

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants