From d743293e564f4c2d20489540998a584c511d7585 Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Sat, 13 Jan 2024 18:11:02 +0200 Subject: [PATCH] clippy & fmt --- client/i18n/src/lib.rs | 18 ++++++++---------- common/src/bin/csv_export/main.rs | 1 + common/src/bin/csv_import/main.rs | 1 + common/src/comp/dialogue.rs | 4 ++-- common/src/comp/inventory/item/mod.rs | 11 +++++------ 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/client/i18n/src/lib.rs b/client/i18n/src/lib.rs index a074f640f6..774c94df00 100644 --- a/client/i18n/src/lib.rs +++ b/client/i18n/src/lib.rs @@ -391,16 +391,14 @@ impl LocalizationGuard { fn get_content_for_lang(lang: &Language, content: &Content) -> Result { match content { Content::Plain(text) => Ok(text.clone()), - Content::Key(key) => { - lang.try_msg(key, None) - .map(Cow::into_owned) - .ok_or_else(|| format!("{key}")) - }, - Content::Attr(key, attr) => { - lang.try_attr(key, attr, None) - .map(Cow::into_owned) - .ok_or_else(|| format!("{key}.{attr}")) - }, + Content::Key(key) => lang + .try_msg(key, None) + .map(Cow::into_owned) + .ok_or_else(|| key.to_string()), + Content::Attr(key, attr) => lang + .try_attr(key, attr, None) + .map(Cow::into_owned) + .ok_or_else(|| format!("{key}.{attr}")), Content::Localized { key, seed, args } => { // flag to detect failure down the chain let mut is_arg_failure = false; diff --git a/common/src/bin/csv_export/main.rs b/common/src/bin/csv_export/main.rs index 24e18b6a6a..dabe050436 100644 --- a/common/src/bin/csv_export/main.rs +++ b/common/src/bin/csv_export/main.rs @@ -1,4 +1,5 @@ #![deny(clippy::clone_on_ref_ptr)] +#![allow(deprecated)] // since item i18n use clap::Parser; use std::{ diff --git a/common/src/bin/csv_import/main.rs b/common/src/bin/csv_import/main.rs index 4bbb546e74..83be0d513c 100644 --- a/common/src/bin/csv_import/main.rs +++ b/common/src/bin/csv_import/main.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] // since item i18n #![deny(clippy::clone_on_ref_ptr)] #![allow(clippy::expect_fun_call)] //TODO: evaluate to remove this and use `unwrap_or_else(panic!(...))` instead diff --git a/common/src/comp/dialogue.rs b/common/src/comp/dialogue.rs index f646d09fb1..b23169900f 100644 --- a/common/src/comp/dialogue.rs +++ b/common/src/comp/dialogue.rs @@ -119,11 +119,11 @@ impl MoodContext { quantity: _, } => { // format!("I need {} {}!", quantity, item.name()) - format!("I need some item, not just any item!") + "I need some item, not just any item!".to_string() }, &MoodContext::MissingItem { item: _ } => { // format!("Someone robbed my {}!", item.name()) - format!("Someone robbed me of my item!") + "Someone robbed me of my item!".to_string() }, } } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 6e39046367..5175246a4d 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -780,6 +780,7 @@ impl ItemDef { tags: Vec, slots: u16, ) -> Self { + #[allow(deprecated)] Self { item_definition_id, name: "test item name".to_owned(), @@ -794,6 +795,7 @@ impl ItemDef { #[cfg(test)] pub fn create_test_itemdef_from_kind(kind: ItemKind) -> Self { + #[allow(deprecated)] Self { item_definition_id: "test.item".to_string(), name: "test item name".to_owned(), @@ -1661,18 +1663,15 @@ pub fn all_items_expect() -> Vec { // Grab modular weapons let mut modular_items: Vec = primary_comp_pool .keys() - .map(|(tool, mat_id)| { + .flat_map(|(tool, mat_id)| { let mat = material_parse_table .get(mat_id) .expect("unexpected material ident"); // get all weapons without imposing additional hand restrictions - let its = modular::generate_weapons(*tool, *mat, None) - .expect("failure during modular weapon generation"); - - its + modular::generate_weapons(*tool, *mat, None) + .expect("failure during modular weapon generation") }) - .flatten() .collect(); // 1. Append asset items, that should include pretty much everything,