Skip to content

feat: add NoneAsZero adapter for Option<NonZero*>#954

Merged
jonasbb merged 1 commit into
jonasbb:masterfrom
SAY-5:feat-none-as-zero
May 18, 2026
Merged

feat: add NoneAsZero adapter for Option<NonZero*>#954
jonasbb merged 1 commit into
jonasbb:masterfrom
SAY-5:feat-none-as-zero

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 13, 2026

Copy link
Copy Markdown
Contributor

Closes #486.

Adds a NoneAsZero adapter so Option<NonZeroU32> (and the other NonZero variants) round-trip losslessly through a single integer field, encoding None as 0 and Some(n) as n. Implementations cover NonZeroU8/U16/U32/U64/U128/Usize and the signed counterparts; includes rustdoc, a transformations guide entry, and a behavior test.

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.60%. Comparing base (f1b06c7) to head (6cb1345).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #954      +/-   ##
==========================================
+ Coverage   68.52%   68.60%   +0.08%     
==========================================
  Files          37       37              
  Lines        9759     9784      +25     
==========================================
+ Hits         6687     6712      +25     
  Misses       3072     3072              

☔ View full report in Codecov by Sentry.
📢 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.

@jonasbb

jonasbb commented May 18, 2026

Copy link
Copy Markdown
Owner

Thank you :) This all looks very nice.

@jonasbb jonasbb merged commit 3b4b80f into jonasbb:master May 18, 2026
23 checks passed
jonasbb added a commit that referenced this pull request May 18, 2026
pull Bot pushed a commit to transparencies/serde_with that referenced this pull request May 18, 2026
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.

Serialize an Option<NonZeroT> as T

2 participants