Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fix(console): reduce decimal digits in UI #402
fix(console): reduce decimal digits in UI #402
Changes from all commits
5995376
d5a59ad
d6f934a
8a382f3
4c62307
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
it's probably worth documenting what the
width
value does here, and what the difference between passingNone
andSome
(andNone
versusSome(0)
) is?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.
Style question here. An
Option<usize>
seemed like a good idea at the time, butNone
andSome(0)
are equivalent. Do you have any opinion on the merits of just passing a bareusize
instead?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.
You could also use an
Option<NonZeroUsize>
i suppose (which has the same representation as a singleusize
, with the actual zero value representingNone
)...but this is an internal API, so misuse-resistent API design is less important. I definitely preferNone
to indicate "no width limit" than 0, though --- when reading the code you might expect "0 width" to mean "no characters", i guess?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.
Okay. That sounds like a better option (using NonZero). Internal or no, as you said, None to mean no width restriction makes more sense than 0. I'll document the function too, so that it's clear. Thanks!
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.
sounds good to me!
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.
So, this is a bit ugly because I now need this line when declaring
DUR_LEN
or I need to beunwrap
ing in a bunch of places becausenew
returns aOption<NonZeroUsize>
.https://github.com/tokio-rs/console/pull/402/files#diff-295fe639b204aaddc6b81e4c68fbb9bc7f2fb3aef43fbca622e99620dfc7debaR22-R23
Thoughts? Should I just go back to the
Option<usize>
and explain thatSome(0)
andNone
are equivalent?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.
ugh, that's annoying. i would prefer not to put unsafe code in the const. at the callsite, we could call
time_units(..., NonZeroUsize::new(DUR_LEN))
but that's more verbose. i think it would be fine to allowSome(0)
andNone
to mean the same thing, or just get rid of the option...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.
Changed it back to
Option<usize>
.