From 3cdaacabac69e67b49349e8f7b153820947b119a Mon Sep 17 00:00:00 2001 From: ju6ge Date: Thu, 13 Mar 2025 20:31:34 +0100 Subject: [PATCH] fix message vector filling --- rust/src/log/mod.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rust/src/log/mod.rs b/rust/src/log/mod.rs index 0832746..1a8434a 100644 --- a/rust/src/log/mod.rs +++ b/rust/src/log/mod.rs @@ -189,22 +189,23 @@ pub enum LogMessage { #[derive(Serialize)] pub struct MessageTranslation { msg_type: LogMessage, - message: &'static str + message: &'static str, } impl From<&LogMessage> for MessageTranslation { fn from(value: &LogMessage) -> Self { - Self { msg_type: value.clone(), message: value.into() } + Self { + msg_type: value.clone(), + message: value.into(), + } } } impl LogMessage { pub fn to_log_localisation_config() -> Vec { - let mut array = Vec::with_capacity(LogMessage::len()); - - for msg_type in LogMessage::iter() { - array[msg_type.ordinal()] = (&msg_type).into(); - } - array + Vec::from_iter((0..LogMessage::len()).map(|i| { + let msg_type = LogMessage::from_ordinal(i).unwrap(); + (&msg_type).into() + })) } }