clippy & fmt

This commit is contained in:
juliancoffee 2024-01-13 18:11:02 +02:00
parent 1748b5e76f
commit d743293e56
5 changed files with 17 additions and 18 deletions

View File

@ -391,16 +391,14 @@ impl LocalizationGuard {
fn get_content_for_lang(lang: &Language, content: &Content) -> Result<String, String> { fn get_content_for_lang(lang: &Language, content: &Content) -> Result<String, String> {
match content { match content {
Content::Plain(text) => Ok(text.clone()), Content::Plain(text) => Ok(text.clone()),
Content::Key(key) => { Content::Key(key) => lang
lang.try_msg(key, None) .try_msg(key, None)
.map(Cow::into_owned) .map(Cow::into_owned)
.ok_or_else(|| format!("{key}")) .ok_or_else(|| key.to_string()),
}, Content::Attr(key, attr) => lang
Content::Attr(key, attr) => { .try_attr(key, attr, None)
lang.try_attr(key, attr, None) .map(Cow::into_owned)
.map(Cow::into_owned) .ok_or_else(|| format!("{key}.{attr}")),
.ok_or_else(|| format!("{key}.{attr}"))
},
Content::Localized { key, seed, args } => { Content::Localized { key, seed, args } => {
// flag to detect failure down the chain // flag to detect failure down the chain
let mut is_arg_failure = false; let mut is_arg_failure = false;

View File

@ -1,4 +1,5 @@
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![allow(deprecated)] // since item i18n
use clap::Parser; use clap::Parser;
use std::{ use std::{

View File

@ -1,3 +1,4 @@
#![allow(deprecated)] // since item i18n
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![allow(clippy::expect_fun_call)] //TODO: evaluate to remove this and use `unwrap_or_else(panic!(...))` instead #![allow(clippy::expect_fun_call)] //TODO: evaluate to remove this and use `unwrap_or_else(panic!(...))` instead

View File

@ -119,11 +119,11 @@ impl MoodContext {
quantity: _, quantity: _,
} => { } => {
// format!("I need {} {}!", quantity, item.name()) // 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: _ } => { &MoodContext::MissingItem { item: _ } => {
// format!("Someone robbed my {}!", item.name()) // format!("Someone robbed my {}!", item.name())
format!("Someone robbed me of my item!") "Someone robbed me of my item!".to_string()
}, },
} }
} }

View File

@ -780,6 +780,7 @@ impl ItemDef {
tags: Vec<ItemTag>, tags: Vec<ItemTag>,
slots: u16, slots: u16,
) -> Self { ) -> Self {
#[allow(deprecated)]
Self { Self {
item_definition_id, item_definition_id,
name: "test item name".to_owned(), name: "test item name".to_owned(),
@ -794,6 +795,7 @@ impl ItemDef {
#[cfg(test)] #[cfg(test)]
pub fn create_test_itemdef_from_kind(kind: ItemKind) -> Self { pub fn create_test_itemdef_from_kind(kind: ItemKind) -> Self {
#[allow(deprecated)]
Self { Self {
item_definition_id: "test.item".to_string(), item_definition_id: "test.item".to_string(),
name: "test item name".to_owned(), name: "test item name".to_owned(),
@ -1661,18 +1663,15 @@ pub fn all_items_expect() -> Vec<Item> {
// Grab modular weapons // Grab modular weapons
let mut modular_items: Vec<Item> = primary_comp_pool let mut modular_items: Vec<Item> = primary_comp_pool
.keys() .keys()
.map(|(tool, mat_id)| { .flat_map(|(tool, mat_id)| {
let mat = material_parse_table let mat = material_parse_table
.get(mat_id) .get(mat_id)
.expect("unexpected material ident"); .expect("unexpected material ident");
// get all weapons without imposing additional hand restrictions // get all weapons without imposing additional hand restrictions
let its = modular::generate_weapons(*tool, *mat, None) modular::generate_weapons(*tool, *mat, None)
.expect("failure during modular weapon generation"); .expect("failure during modular weapon generation")
its
}) })
.flatten()
.collect(); .collect();
// 1. Append asset items, that should include pretty much everything, // 1. Append asset items, that should include pretty much everything,