Skip to content

Commit

Permalink
Taking advantage of derivable_impls for the default value of the en…
Browse files Browse the repository at this point in the history
  • Loading branch information
detro committed Mar 13, 2023
1 parent d704a56 commit 5460c2b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/rdkafka.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::ValueEnum;
///
/// The documentation is lifted directly from the `librdkafka` configuration
/// [page](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md).
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default)]
#[value(rename_all = "snake_case")]
pub enum PartitionerConfig {
/// Random distribution.
Expand All @@ -14,6 +14,7 @@ pub enum PartitionerConfig {
Consistent,

/// CRC32 hash of key (Empty and NULL keys are randomly partitioned).
#[default]
ConsistentRandom,

/// Java Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition).
Expand Down Expand Up @@ -43,9 +44,3 @@ impl PartitionerConfig {
}
}
}

impl Default for PartitionerConfig {
fn default() -> Self {
PartitionerConfig::ConsistentRandom
}
}

0 comments on commit 5460c2b

Please sign in to comment.