From 5fa6efa940935c46a8cbdd3658977730d456436e Mon Sep 17 00:00:00 2001 From: Leigh <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:32:52 +0000 Subject: [PATCH] derive Default for cli format enums --- src/cli/compare.rs | 9 ++------- src/cli/decode.rs | 18 ++++-------------- src/cli/encode.rs | 18 ++++-------------- src/cli/generate/arbitrary.rs | 9 ++------- src/cli/generate/default.rs | 9 ++------- src/cli/guess.rs | 18 ++++-------------- src/cli/types/list.rs | 9 ++------- src/cli/types/schema.rs | 9 ++------- src/cli/types/schema_files.rs | 9 ++------- 9 files changed, 24 insertions(+), 84 deletions(-) diff --git a/src/cli/compare.rs b/src/cli/compare.rs index 952d76399..326a5c1ab 100644 --- a/src/cli/compare.rs +++ b/src/cli/compare.rs @@ -46,18 +46,13 @@ pub struct Cmd { pub input: InputFormat, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum InputFormat { Single, + #[default] SingleBase64, } -impl Default for InputFormat { - fn default() -> Self { - Self::SingleBase64 - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x { diff --git a/src/cli/decode.rs b/src/cli/decode.rs index aad5eb581..69bfa9b2e 100644 --- a/src/cli/decode.rs +++ b/src/cli/decode.rs @@ -43,23 +43,19 @@ pub struct Cmd { pub output_format: OutputFormat, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum InputFormat { Single, SingleBase64, Stream, + #[default] StreamBase64, StreamFramed, } -impl Default for InputFormat { - fn default() -> Self { - Self::StreamBase64 - } -} - -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { + #[default] Json, JsonFormatted, Text, @@ -67,12 +63,6 @@ pub enum OutputFormat { RustDebugFormatted, } -impl Default for OutputFormat { - fn default() -> Self { - Self::Json - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x { diff --git a/src/cli/encode.rs b/src/cli/encode.rs index 5277e274d..b3cfcce98 100644 --- a/src/cli/encode.rs +++ b/src/cli/encode.rs @@ -63,32 +63,22 @@ pub struct Cmd { pub output_format: OutputFormat, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum InputFormat { + #[default] Json, } -impl Default for InputFormat { - fn default() -> Self { - Self::Json - } -} - -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { Single, + #[default] SingleBase64, Stream, // TODO: StreamBase64, // TODO: StreamFramed, } -impl Default for OutputFormat { - fn default() -> Self { - Self::SingleBase64 - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x { diff --git a/src/cli/generate/arbitrary.rs b/src/cli/generate/arbitrary.rs index dd2cf9edf..f1ae96019 100644 --- a/src/cli/generate/arbitrary.rs +++ b/src/cli/generate/arbitrary.rs @@ -50,9 +50,10 @@ pub struct Cmd { pub hint_attempts: u64, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { Single, + #[default] SingleBase64, // TODO: Stream, // TODO: StreamBase64, @@ -62,12 +63,6 @@ pub enum OutputFormat { Text, } -impl Default for OutputFormat { - fn default() -> Self { - Self::SingleBase64 - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x { diff --git a/src/cli/generate/default.rs b/src/cli/generate/default.rs index 8144a045c..6e59a7335 100644 --- a/src/cli/generate/default.rs +++ b/src/cli/generate/default.rs @@ -33,9 +33,10 @@ pub struct Cmd { pub output_format: OutputFormat, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { Single, + #[default] SingleBase64, // TODO: Stream, // TODO: StreamBase64, @@ -45,12 +46,6 @@ pub enum OutputFormat { Text, } -impl Default for OutputFormat { - fn default() -> Self { - Self::SingleBase64 - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x { diff --git a/src/cli/guess.rs b/src/cli/guess.rs index c0f0fa218..fae40b810 100644 --- a/src/cli/guess.rs +++ b/src/cli/guess.rs @@ -36,32 +36,22 @@ pub struct Cmd { pub certainty: usize, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum InputFormat { Single, + #[default] SingleBase64, Stream, StreamBase64, StreamFramed, } -impl Default for InputFormat { - fn default() -> Self { - Self::SingleBase64 - } -} - -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { + #[default] List, } -impl Default for OutputFormat { - fn default() -> Self { - Self::List - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x { diff --git a/src/cli/types/list.rs b/src/cli/types/list.rs index 458abc6a0..9dc2e63e2 100644 --- a/src/cli/types/list.rs +++ b/src/cli/types/list.rs @@ -8,19 +8,14 @@ pub struct Cmd { pub output: OutputFormat, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { + #[default] Plain, Json, JsonFormatted, } -impl Default for OutputFormat { - fn default() -> Self { - Self::Plain - } -} - impl Cmd { /// Run the CLIs types list command. /// diff --git a/src/cli/types/schema.rs b/src/cli/types/schema.rs index 107d136b8..fe7253d54 100644 --- a/src/cli/types/schema.rs +++ b/src/cli/types/schema.rs @@ -22,17 +22,12 @@ pub struct Cmd { pub output: OutputFormat, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { + #[default] JsonSchemaDraft201909, } -impl Default for OutputFormat { - fn default() -> Self { - Self::JsonSchemaDraft201909 - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x { diff --git a/src/cli/types/schema_files.rs b/src/cli/types/schema_files.rs index 3fa7e5371..52992abf1 100644 --- a/src/cli/types/schema_files.rs +++ b/src/cli/types/schema_files.rs @@ -24,17 +24,12 @@ pub struct Cmd { pub output: OutputFormat, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] +#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)] pub enum OutputFormat { + #[default] JsonSchemaDraft201909, } -impl Default for OutputFormat { - fn default() -> Self { - Self::JsonSchemaDraft201909 - } -} - // TODO: Remove run_x macro, it exists only to reduce the diff from when curr/next // channels existed and each had their own run_curr/run_next invocation. macro_rules! run_x {