fix(derive): preserve .0 in float default_value_t help#6383
Closed
leno23 wants to merge 1 commit into
Closed
Conversation
Float defaults like 1.0 were shown as [default: 1] because ToString
drops trailing zeros. Format whole-number floats as {n}.0 in help.
Fixes clap-rs#6249.
Co-authored-by: Cursor <cursoragent@cursor.com>
Member
|
For context, this contributor opened ~13 PRs across several of my repos within a very short period of time where al most all were invalid, the opposite direction of what has been expressed, no design ready yet, or a host of other reasons why the related issues were open without addressing any of that. I have given them a warning that any further PRs along these lines and they will be banned. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
#[arg(default_value_t = 1.0)]showed[default: 1]in help becauseToStringdrops trailing zeros on floats.Format whole-number floats as
{n}.0when rendering default values in help text.Fixes #6249.
Test plan
cargo test --features derive,help,usage --test derive default_value_t_float