Refactor: Use derive Default attribute instead of impl blocks - #561
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Replaces manual CLI format defaults with Rust’s derived Default implementation while preserving behavior.
Changes:
- Adds
Defaultderives 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
requested review from
a team and
dmkozh
and removed request for
dmkozh
July 28, 2026 10:15
leighmcculloch
enabled auto-merge
July 28, 2026 11:02
dmkozh
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace the hand-written
impl Defaultblocks on the CLI'sInputFormatandOutputFormatenums with#[derive(Default)]and a#[default]variant attribute.Why
Nine copies of a six-line
impl Defaultexpress 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