-
Notifications
You must be signed in to change notification settings - Fork 56
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
Underscores in numeric literals #155
Comments
We received a similar feature request in rustfmt a couple months ago, but ultimately decided against trying to support it at that time |
On Thu, Jul 23, 2020 at 07:36:59AM -0700, varkor wrote:
There appears to be no guideline for underscores at the moment. Perhaps it is intended to be left to the programmer, but in particular, I think specifying whether or not underscores are encouraged between a literal and its type, e.g. `5u32` vs `5_u32` could be helpful (or specifically excluded).
Underscores are available for the programmer to use or not use, at their
preference, and to the best of my knowledge, rustfmt will not change the
format you use for numeric literals.
I don't think, in general, we could provide a guideline that makes sense
for all cases. Sometimes you'd want to use `_` as a thousands separator
or a byte/word/dword separator, sometimes you'd want to use it to
separate distinct bitfields, sometimes you don't want to use it at all.
(I personally don't feel there's much value in putting an `_` between a
number and its type suffix; I find `5u32` more readable. That's a
personal opinion.)
|
Closing as I agree with Josh's point about this not being applicable for inclusion within the style guide. Separately, if anyone feels strongly enough that they'd like to have the feature then I'd be receptive to reviewing a PR for rustfmt that gives the user the option. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There appears to be no guideline for underscores at the moment. Perhaps it is intended to be left to the programmer, but in particular, I think specifying whether or not underscores are encouraged between a literal and its type, e.g.
5u32
vs5_u32
could be helpful (or specifically excluded).The text was updated successfully, but these errors were encountered: