Skip to content

fix: preserve shortest float output with non_trailing_zero - #243

Merged
liuq19 merged 1 commit into
cloudwego:mainfrom
HerrCai0907:fix/non-trailing-zero-float-format
Sep 11, 2026
Merged

liuq19 merged 1 commit into
cloudwego:mainfrom
HerrCai0907:fix/non-trailing-zero-float-format

Conversation

@HerrCai0907

Copy link
Copy Markdown
Contributor

Summary

  • limit the f32 integer fast path under non_trailing_zero to the safe prefix where it matches shortest-float JSON output
  • fall back to zmij::format_finite and trim only a .0 suffix for larger integral floats
  • apply the same safe-prefix handling to f64 to avoid incorrect large integer fast-path output
  • add regression coverage for large f32, scientific notation, and f64 boundary cases

Test

  • cargo test test_serialize_float_non_trailing_zero
  • cargo test --features non_trailing_zero test_serialize_float_non_trailing_zero
  • cargo fmt --check

Note: cargo fmt --check prints existing nightly-only rustfmt configuration warnings, but exits successfully.

@CLAassistant

CLAassistant commented Sep 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.23%. Comparing base (03545a9) to head (4b3e644).

Files with missing lines Patch % Lines
src/format.rs 93.75% 1 Missing ⚠️
src/lazyvalue/value.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #243      +/-   ##
==========================================
+ Coverage   71.16%   71.23%   +0.07%     
==========================================
  Files          42       42              
  Lines        9762     9786      +24     
==========================================
+ Hits         6947     6971      +24     
  Misses       2815     2815              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HerrCai0907
HerrCai0907 force-pushed the fix/non-trailing-zero-float-format branch 2 times, most recently from 2134835 to 8275937 Compare September 11, 2026 05:00
liuq19
liuq19 previously approved these changes Sep 11, 2026

@liuq19 liuq19 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Co-authored-by: TRAE CLI <traecli@bytedance.com>
@HerrCai0907
HerrCai0907 force-pushed the fix/non-trailing-zero-float-format branch from 3f4b874 to 4b3e644 Compare September 11, 2026 05:44

@liuq19 liuq19 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@liuq19
liuq19 merged commit 7eca25c into cloudwego:main Sep 11, 2026
22 checks passed
@HerrCai0907
HerrCai0907 deleted the fix/non-trailing-zero-float-format branch September 11, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants