Skip to content

fix(derive): preserve .0 in float default_value_t help#6383

Closed
leno23 wants to merge 1 commit into
clap-rs:masterfrom
leno23:fix/issue-6249-float-default-help
Closed

fix(derive): preserve .0 in float default_value_t help#6383
leno23 wants to merge 1 commit into
clap-rs:masterfrom
leno23:fix/issue-6249-float-default-help

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

#[arg(default_value_t = 1.0)] showed [default: 1] in help because ToString drops trailing zeros on floats.

Format whole-number floats as {n}.0 when rendering default values in help text.

Fixes #6249.

Test plan

  • cargo test --features derive,help,usage --test derive default_value_t_float

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>
@epage epage closed this May 18, 2026
@epage
Copy link
Copy Markdown
Member

epage commented May 18, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clap help trims .0 from float default values

2 participants