From 6b1dedc10a32aba8d6d2405bc95d0664f6551afd Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Wed, 8 Oct 2025 06:37:54 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(config):=20correct=20plurali?= =?UTF-8?q?zation=20of=20time=20periods=20in=20EolRule=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix pluralization logic for day, week, month, and year - avoid redundant match arms by pushing 's' when count > 1 --- src/config/eol_rule.rs | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/config/eol_rule.rs b/src/config/eol_rule.rs index 598bdfe..da40240 100644 --- a/src/config/eol_rule.rs +++ b/src/config/eol_rule.rs @@ -19,38 +19,18 @@ impl fmt::Display for EolRule { if !self.retention.is_empty() { let count = &self.retention[2..]; let count = count.parse::().unwrap(); - let period = match self.retention.chars().nth(0) { - Some('d') => { - if count == 1 { - "day" - } else { - "days" - } - } - Some('w') => { - if count == 1 { - "week" - } else { - "weeks" - } - } - Some('m') => { - if count == 1 { - "month" - } else { - "months" - } - } - Some('y') => { - if count == 1 { - "year" - } else { - "years" - } - } + let mut period = match self.retention.chars().nth(0) { + Some('d') => "day", + Some('w') => "week", + Some('m') => "month", + Some('y') => "year", Some(_) => unreachable!(), None => unreachable!(), - }; + } + .to_string(); + if count > 1 { + period.push('s'); + } write!( f, "Rule #{} is active on {} and applies when the message is {count} {period} old.",