-
Notifications
You must be signed in to change notification settings - Fork 806
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
For many
and fold
, consider ..0
an invalid range, just as 0..0
is
#1632
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 4050233552
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching these. It has been a long while since I last touched this piece of the code but the off-by-one fixes seem correct to me. I'm just not sure about removing the explicit self.end == 0
checks. Those still seem necessary to me.
if self.end == 0 { | ||
1..0 | ||
} else { | ||
0..self.end - 1 | ||
} | ||
0..self.end - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this panic when overflow checking is enabled (such as when building with debug)?
And even if the underflow does not panic it would return 0..usize::MAX
as the iterator for a range of x..0
. This is incorrect because the range should be empty. Similar reasoning applies to the other range implementations.
Pull Request Test Coverage Report for Build 4050233552Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
1 similar comment
Pull Request Test Coverage Report for Build 4050233552Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
nom::multi::many
andnom::many::fold
consider empty ranges, as checked byNomRange::is_inverted
, to be invalid. Unfortunately, that method is incorrectly implemented forRangeTo
, meaning that..0
is not considered invalid when it should be.While I'm here, I also fixed up off-by-one errors in
RangeFrom::bounded_iter
andRangeFull::bounded_iter
.