-
Notifications
You must be signed in to change notification settings - Fork 20
Implement Step for NonZeroUxx #130
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
Comments
If all you want to do is iterate, why can't you use the underlying type? Though in general I don't see a reason to not implement step, so this seems like a good idea. In terms of the ACP, it should be mentioned that ranges need to implement step for them to be iterable, hence why this ACP is necessary. |
That's my alternative solution now. The range is used as a parameter to a |
I posted about this in the Internals Forum. There I state another (although a bit esoteric) use case: when solving Sudokus letting |
In my use case, I was developing an ECS library where entity IDs are always nonzero (to optimize |
I was bitten by this today. |
Is there a reason not to move forward on this or does it just need someone to actually do the work? |
libs-api discusses change proposals during meetings, there's a backlog and people open new ones almost as fast as they get processed so it just takes a while. In principle the ACP process is optional and one can make a PR instead, but then one may be faced with the same questions about motivation, alternatives, etc. especially when the reviewer is unsure if the addition makes sense. |
We discussed this in the libs-api meeting. We're happy to see these impls added. Feel free to open a PR to rust-lang/rust to add them, at which point we'll propose an FCP for official team confirmation before stabilziation. |
Implement Step for NonZero unsigned integers as discussed in [libs-team#130][1]. [1]: rust-lang/libs-team#130 `step_nonzero_impls` was adapted from `step_integer_impls` and the tests were adapted from the step tests.
Implement Step for NonZero unsigned integers as discussed in [libs-team#130][1]. [1]: rust-lang/libs-team#130 `step_nonzero_impls` was adapted from `step_integer_impls` and the tests were adapted from the step tests.
Implement Step for NonZero unsigned integers as discussed in [libs-team#130][1]. [1]: rust-lang/libs-team#130 `step_nonzero_impls` was adapted from `step_integer_impls` and the tests were adapted from the step tests.
Proposal
Problem statement
Ranges of non-zero unsigned integers does not contain zero, and should be step-able.
Motivation, use-cases
I want to iterate over a
Range<NonZeroUsize>
.Solution sketches
It might be tricky to implement
backward_checked
properly since we cannot guarantee that the inputusize
is less thanstart
.It is also inconsistent that NonZeroIxx are not implemented.
Links and related work
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: