From 55079369e6f86693cc8a7b320fecee1a77954e73 Mon Sep 17 00:00:00 2001 From: mgros Date: Fri, 25 Sep 2026 04:39:13 +0200 Subject: [PATCH] replace custom constructor with struct literals for TTSCommandRule --- src/tts.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/tts.rs b/src/tts.rs index c2f951b39..134c96251 100644 --- a/src/tts.rs +++ b/src/tts.rs @@ -243,16 +243,6 @@ impl fmt::Display for TTSCommandRule { } -impl TTSCommandRule { - pub fn new(command: TTSCommand, value: TTSCommandValue, replacements: ReplacementArray) -> TTSCommandRule { - return TTSCommandRule{ - command, - value, - replacements - } - } -} - /// Supported TTS engines /// These types should do something for all the TTSCommands #[allow(clippy::upper_case_acronyms)] @@ -348,7 +338,11 @@ impl TTS { TTSCommandValue::String(tts_str_value.to_string()) }, }; - return Ok( Box::new( TTSCommandRule::new(tts_enum, tts_command_value, replacements) ) ); + return Ok(Box::new(TTSCommandRule { + command: tts_enum, + value: tts_command_value, + replacements, + })); } /// The rule called to execute the TTSCommand `command` @@ -691,11 +685,11 @@ impl TTS { } let pause = std::cmp::min(3000, ((2 * before_len + after_len)/48) * 128); // create a TTSCommandRule so we reuse code - let command = TTSCommandRule::new( - TTSCommand::Pause, - TTSCommandValue::Number(pause as f64), - ReplacementArray::build_empty(), - ); + let command = TTSCommandRule { + command: TTSCommand::Pause, + value: TTSCommandValue::Number(pause as f64), + replacements: ReplacementArray::build_empty(), + }; return match self { TTS::None => self.get_string_none(&command, prefs, true), TTS::SSML => self.get_string_ssml(&command, prefs, true),