From 2367c517f332352af1ff8ca894aaf9b42af4ead7 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Jun 2025 09:06:32 +0200 Subject: clippy: Use slice instead of vec when possible --- server/common/src/grit.rs | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'server/common/src') diff --git a/server/common/src/grit.rs b/server/common/src/grit.rs index 9d01dac..4a71ade 100644 --- a/server/common/src/grit.rs +++ b/server/common/src/grit.rs @@ -137,7 +137,7 @@ pub struct TranslationUnit { pub target: Vec, } -fn get_opt_attribute<'a>(attributes: &'a Vec, name: &str) -> Option<&'a str> { +fn get_opt_attribute<'a>(attributes: &'a [OwnedAttribute], name: &str) -> Option<&'a str> { for attribute in attributes { if attribute.name.local_name == name { return Some(attribute.value.as_str()); @@ -146,12 +146,12 @@ fn get_opt_attribute<'a>(attributes: &'a Vec, name: &str) -> Opt None } -fn get_attribute<'a>(attributes: &'a Vec, name: &str) -> anyhow::Result<&'a str> { +fn get_attribute<'a>(attributes: &'a [OwnedAttribute], name: &str) -> anyhow::Result<&'a str> { get_opt_attribute(attributes, name).ok_or(Error::msg(format!("Expected attribute {name}"))) } fn parse_grit_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let current_release = get_attribute(attributes, "current_release")?.parse::()?; @@ -215,7 +215,7 @@ fn parse_grit_element( } fn parse_outputs_element( - _attributes: &Vec, + _attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let mut output = Vec::::new(); @@ -264,7 +264,7 @@ fn parse_outputs_element( } fn parse_output_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let filename = get_attribute(attributes, "filename")?; @@ -311,7 +311,7 @@ fn parse_output_element( } fn parse_if_output_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let expr = get_attribute(attributes, "expr")?; @@ -364,7 +364,7 @@ fn parse_if_output_element( } fn parse_translations_element( - _attributes: &Vec, + _attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let mut file = Vec::::new(); @@ -413,7 +413,7 @@ fn parse_translations_element( } fn parse_file_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let path = get_attribute(attributes, "path")?; @@ -458,7 +458,7 @@ fn parse_file_element( } fn parse_if_file_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let expr = get_attribute(attributes, "expr")?; @@ -511,7 +511,7 @@ fn parse_if_file_element( } fn parse_release_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let allow_pseudo = get_attribute(attributes, "allow_pseudo")?.parse::()?; @@ -563,7 +563,7 @@ fn parse_release_element( } fn parse_messages_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let fallback_to_english = get_attribute(attributes, "fallback_to_english")?.parse::()?; @@ -623,7 +623,7 @@ fn parse_messages_element( } fn parse_message_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let desc = get_attribute(attributes, "desc")?; @@ -703,7 +703,7 @@ fn parse_message_element( } fn parse_if_message_part_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let expr = get_attribute(attributes, "expr")?; @@ -763,7 +763,7 @@ fn parse_if_message_part_element( } fn parse_if_message_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let expr = get_attribute(attributes, "expr")?; @@ -820,7 +820,7 @@ fn parse_if_message_element( } fn parse_part_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let file = get_attribute(attributes, "file")?; @@ -864,7 +864,7 @@ fn parse_part_element( } fn parse_placeholder_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let name = get_attribute(attributes, "name")?; @@ -925,7 +925,7 @@ fn parse_placeholder_element( } fn parse_placeholder_example_element( - _attributes: &Vec, + _attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let mut content = String::new(); @@ -965,7 +965,7 @@ fn parse_placeholder_example_element( } fn parse_grit_part_element( - _attributes: &Vec, + _attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let mut messages = Vec::::new(); @@ -1247,7 +1247,7 @@ pub fn get_message_id(message: &Message) -> i64 { } fn parse_translation_unit_target_element( - _attributes: &Vec, + _attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result> { let mut content = Vec::::new(); @@ -1316,7 +1316,7 @@ fn parse_translation_unit_target_element( } fn parse_translation_placeholder_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let id = get_attribute(attributes, "id")?; @@ -1358,7 +1358,7 @@ fn parse_translation_placeholder_element( } fn parse_translation_unit_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let id = get_attribute(attributes, "id")?.parse::()?; @@ -1409,7 +1409,7 @@ fn parse_translation_unit_element( } fn parse_translation_body_element( - _attributes: &Vec, + _attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result> { let mut units = Vec::::new(); @@ -1452,7 +1452,7 @@ fn parse_translation_body_element( } fn parse_translation_file_element( - attributes: &Vec, + attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let target_language = get_attribute(attributes, "target-language")?; @@ -1503,7 +1503,7 @@ fn parse_translation_file_element( } fn parse_xliff_element( - _attributes: &Vec, + _attributes: &[OwnedAttribute], reader: &mut EventReader, ) -> anyhow::Result { let mut file = VecDeque::::new(); -- cgit v1.2.3-70-g09d2