Skip to content

fix: add .unwrap() to rates.set() calls in doc examples (issue #180 fix 5)#183

Merged
mfirhas merged 1 commit into
masterfrom
copilot/fix-issue-180
May 19, 2026
Merged

fix: add .unwrap() to rates.set() calls in doc examples (issue #180 fix 5)#183
mfirhas merged 1 commit into
masterfrom
copilot/fix-issue-180

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Fixes No.5 from issue #180.

Problem

ExchangeRates::set returns Result<(), MoneyError>, but several doc examples called it without handling the result:

rates.set(EUR::CODE, dec!(0.8));   // Result ignored
rates.set(IDR::CODE, 17_000);      // Result ignored

This inconsistency (compared to the set method's own doc example which correctly used .unwrap()) teaches users that the Result can be silently discarded, hiding potential OverflowErrors.

Fix

Added .unwrap() to all rates.set(...) calls in doc examples that previously ignored the returned Result:

  • Exchange::convert doc example (lines 66–67)
  • ExchangeRates struct-level doc example (lines 224–227)
  • ExchangeRates::get doc example (lines 413–417)
  • ExchangeRates::get_pair doc example (lines 434–438)

Verification

  • make all — all 1502 tests pass, doc tests pass
  • make lcov — coverage report generated successfully

@mfirhas mfirhas marked this pull request as ready for review May 19, 2026 23:31
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mfirhas mfirhas merged commit f71f063 into master May 19, 2026
6 checks passed
@mfirhas mfirhas deleted the copilot/fix-issue-180 branch May 19, 2026 23:36
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.

3 participants