Skip to content

Refactor: Use derive Default attribute instead of impl blocks - #561

Merged
leighmcculloch merged 1 commit into
mainfrom
derive-default-for-cli-formats
Jul 28, 2026
Merged

Refactor: Use derive Default attribute instead of impl blocks#561
leighmcculloch merged 1 commit into
mainfrom
derive-default-for-cli-formats

Conversation

@leighmcculloch

@leighmcculloch leighmcculloch commented Jul 28, 2026

Copy link
Copy Markdown
Member

What

Replace the hand-written impl Default blocks on the CLI's InputFormat and OutputFormat enums with #[derive(Default)] and a #[default] variant attribute.

Why

Nine copies of a six-line impl Default express nothing the derive can't, and the default variant is easier to spot on the variant itself than in a separate impl below the enum.

Broken out of #560, which requires the change to handle a newer version of clippy. We can make the change now though as its a good non-functional refactor.

Known limitations

N/A

Copilot AI review requested due to automatic review settings July 28, 2026 10:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Replaces manual CLI format defaults with Rust’s derived Default implementation while preserving behavior.

Changes:

  • Adds Default derives to input/output format enums.
  • Marks the existing default variants with #[default].
  • Removes 12 redundant manual implementations.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/cli/types/schema.rs Derives the schema output default.
src/cli/types/schema_files.rs Derives the schema-files output default.
src/cli/types/list.rs Derives the list output default.
src/cli/guess.rs Derives guess input and output defaults.
src/cli/generate/default.rs Derives the default-generator output default.
src/cli/generate/arbitrary.rs Derives the arbitrary-generator output default.
src/cli/encode.rs Derives encode input and output defaults.
src/cli/decode.rs Derives decode input and output defaults.
src/cli/compare.rs Derives the compare input default.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leighmcculloch
leighmcculloch requested review from a team and dmkozh and removed request for dmkozh July 28, 2026 10:15
@leighmcculloch
leighmcculloch enabled auto-merge July 28, 2026 11:02
@leighmcculloch
leighmcculloch added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit 3a197d4 Jul 28, 2026
462 checks passed
@leighmcculloch
leighmcculloch deleted the derive-default-for-cli-formats branch July 28, 2026 17:45
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