Skip to content

Make NonZero<char> possible #141001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented May 14, 2025

I'd like to use NonZero<char> for representing units of CStr in https://github.com/rust-lang/literal-escaper

@rustbot
Copy link
Collaborator

rustbot commented May 14, 2025

r? @joboet

rustbot has assigned @joboet.
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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 14, 2025
@hanna-kruppe
Copy link
Contributor

It’s not clear from the diff, but I guess since NonZero<T> works by trait impls on T, this can’t be feature-gated and would immediately allow NonZero<char> on stable?

@jieyouxu
Copy link
Member

r? libs-api

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label May 14, 2025
@rustbot rustbot assigned joshtriplett and unassigned joboet May 14, 2025
@hkBst
Copy link
Member Author

hkBst commented May 14, 2025

It’s not clear from the diff, but I guess since NonZero<T> works by trait impls on T, this can’t be feature-gated and would immediately allow NonZero<char> on stable?

That's a good point I hadn't considered. I'll look into whether a feature gate is possible.

@tgross35
Copy link
Contributor

Could you add a test so we don't accidentally regress this? library/coretests/tests/num/niche_types.rs doesn't exist yet but probably would be the place.

@hkBst
Copy link
Member Author

hkBst commented May 15, 2025

Could you add a test so we don't accidentally regress this? library/coretests/tests/num/niche_types.rs doesn't exist yet but probably would be the place.

Do you mean a test that just uses all the possible NonZero-able types as NonZeros? Meaning they are tested for being possible. Or is there another thing you meant?

@tgross35
Copy link
Contributor

I did only mean something to check basic usage of the type, and was only thinking of char since the other types are covered by the NonZeroUxx doctests. It wouldn't be bad to just add the same kind of test for all the types, though.

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-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
7 participants