-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Unable to create a range to max value, e.g. 100..256
for a Range<u8>
#23635
Comments
Even worse: let r: std::ops::Range<u8> = 100..(255 + 1); We don't have a warning here whereas it displays: 100..0 But it displays a warning in this case: let r: std::ops::Range<u8> = 100..(257 - 1); Kinda tricky somehow haha. |
|
Note: |
This issue has been superceded by #28237, once that feature is stable, this will be possible. |
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How is one supposed to create a range which includes the maximum value as it's upper bound?
E.g. if I wish to create the range 100 to 255 inclusive for a
u8
, I need use the notation100..256
:The output of which is:
(we do get a warning when we compile though)
I understand why this is happening based on the implementation of Range, and I'm not sure how one would fix it without changing Range to use an inclusive upper bound (even if the notation stays as is). Maybe a better warning might be of use if I can't be solved?
The text was updated successfully, but these errors were encountered: