Skip to content

refactor: derive Default for RequestRequirements - #247

Merged
FalkWoldmann merged 1 commit into
httpmock:masterfrom
danieleades:refactor/request-requirements-default
Aug 7, 2026
Merged

FalkWoldmann merged 1 commit into
httpmock:masterfrom
danieleades:refactor/request-requirements-default

Conversation

@danieleades

@danieleades danieleades commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

What

  • RequestRequirements has 80 fields, all Options. new() listed every one of them as None explicitly; derive(Default) replaces the hand-written Default impl and new() delegates to it (-95 lines).
  • build_mock_definition in src/server/state.rs repeated the same wall of explicit None assignments; it now uses struct-update syntax with ..Default::default() (~-80 lines).
  • Merges duplicate private converters in data.rs: from_string_pair_vec was byte-for-byte identical to to_name_value_string_pair_vec, and from_pattern_vec was a needless clone whose callers pass owned values.

No public API or behaviour changes: derive(Default) produces exactly the all-None value the manual impl did, serde attributes and field order are untouched, so the JSON/YAML serialization shape is unchanged.

Overlap note

The converter cleanup in data.rs also appears in #246 (dead-code removal); the hunks are identical, so the PRs merge cleanly in either order.

Verification

cargo test --all-features unit + integration suites pass locally (122 + 137 tests, including the record/playback tests that exercise the YAML serialization path).

RequestRequirements::new listed all ~80 Option fields as None
explicitly, and build_mock_definition repeated the same wall of None
assignments. Every field is an Option, so Default is derivable and
new() delegates to it. Also merge the duplicate private converters in
data.rs (from_string_pair_vec was identical to
to_name_value_string_pair_vec; from_pattern_vec was a needless clone).
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@FalkWoldmann
FalkWoldmann merged commit c2ce310 into httpmock:master Aug 7, 2026
9 checks passed
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.

2 participants