From 1772962aa86cbfa4cc95352f58011210a352cc2a Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Wed, 20 Sep 2023 15:16:21 -0400 Subject: [PATCH] Implements default trait for new ValueConf --- lading_payload/src/dogstatsd.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lading_payload/src/dogstatsd.rs b/lading_payload/src/dogstatsd.rs index 996768d26..1c303a52d 100644 --- a/lading_payload/src/dogstatsd.rs +++ b/lading_payload/src/dogstatsd.rs @@ -32,13 +32,7 @@ fn contexts() -> ConfRange { } fn value_config() -> ValueConf { - ValueConf { - float_probability: 0.5, // 50% - range: ConfRange::Inclusive { - min: i64::MIN, - max: i64::MAX, - }, - } + ValueConf::default() } // https://docs.datadoghq.com/developers/guide/what-best-practices-are-recommended-for-naming-metrics-and-tags/#rules-and-best-practices-for-naming-metrics @@ -120,6 +114,17 @@ pub struct ValueConf { range: ConfRange, } +impl Default for ValueConf { + fn default() -> Self { + Self { + float_probability: 0.5, // 50% + range: ConfRange::Inclusive { + min: i64::MIN, + max: i64::MAX, + }, + } + } +} /// Range expression for configuration #[derive(Debug, Deserialize, Clone, PartialEq, Copy)] #[serde(rename_all = "snake_case")]