From 57d24d3d00054c4f8625cd27e77db9881fd52718 Mon Sep 17 00:00:00 2001 From: SARDONYX-sard <68905624+SARDONYX-sard@users.noreply.github.com> Date: Fri, 2 Feb 2024 03:09:05 +0900 Subject: [PATCH] refactor(core): apply lint fix --- Cargo.toml | 1 + dar2oar_cli/Cargo.toml | 2 + dar2oar_core/Cargo.toml | 2 + dar2oar_core/src/condition_parser/actor.rs | 2 +- dar2oar_core/src/condition_parser/compare.rs | 4 +- .../src/condition_parser/conditions.rs | 2 +- .../src/condition_parser/dar_interface.rs | 18 +-- dar2oar_core/src/condition_parser/macros.rs | 23 ++-- dar2oar_core/src/conditions/faction_rank.rs | 2 +- .../src/conditions/namespace_config.rs | 10 +- dar2oar_core/src/dar_syntax/error.rs | 16 +-- dar2oar_core/src/dar_syntax/syntax.rs | 40 +++---- dar2oar_core/src/fs/converter/common.rs | 10 +- dar2oar_core/src/fs/converter/support_cmd.rs | 6 +- dar2oar_core/src/fs/mapping_table.rs | 6 +- dar2oar_core/src/fs/path_changer.rs | 4 +- dar2oar_core/src/lib.rs | 107 +++--------------- dar2oar_core/src/values/actor_value.rs | 22 ++-- dar2oar_core/src/values/comparison.rs | 26 ++--- dar2oar_core/src/values/direction_value.rs | 33 +++--- dar2oar_core/src/values/form_value.rs | 2 +- dar2oar_core/src/values/graph_value.rs | 22 ++-- dar2oar_core/src/values/keyword_value.rs | 6 +- dar2oar_core/src/values/literal_value.rs | 2 +- dar2oar_core/src/values/numeric_literal.rs | 24 ++-- dar2oar_core/src/values/numeric_value.rs | 8 +- dar2oar_core/src/values/plugin_value.rs | 19 ++-- dar2oar_core/src/values/static_value.rs | 2 +- dar2oar_core/src/values/type_value.rs | 107 +++++++++--------- frontend/tsconfig.json | 10 +- src-tauri/Cargo.toml | 2 + 31 files changed, 234 insertions(+), 306 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6bd2ca6..d05c342 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace.package] version = "0.5.0" description = "DAR to OAR Converter" +categories = ["compilers", "games", "parsing"] repository = "https://github.com/SARDONYX-sard/dar-to-oar" [workspace] diff --git a/dar2oar_cli/Cargo.toml b/dar2oar_cli/Cargo.toml index 626e96b..db5aaf9 100644 --- a/dar2oar_cli/Cargo.toml +++ b/dar2oar_cli/Cargo.toml @@ -3,6 +3,8 @@ name = "dar2oar_cli" version.workspace = true description = "DAR to OAR Converter CLI" authors = ["SARDONYX-sard"] +categories.workspace = true +keywords = ["converter", "skyrim", "cli"] license = "MIT OR Apache-2.0" repository.workspace = true edition = "2021" diff --git a/dar2oar_core/Cargo.toml b/dar2oar_core/Cargo.toml index b72983b..7b32856 100644 --- a/dar2oar_core/Cargo.toml +++ b/dar2oar_core/Cargo.toml @@ -3,6 +3,8 @@ name = "dar2oar_core" version.workspace = true description = "DAR to OAR Converter Core" authors = ["SARDONYX-sard"] +categories.workspace = true +keywords = ["converter", "skyrim"] license = "MIT OR Apache-2.0" repository.workspace = true edition = "2021" diff --git a/dar2oar_core/src/condition_parser/actor.rs b/dar2oar_core/src/condition_parser/actor.rs index 991a9d9..8e8677c 100644 --- a/dar2oar_core/src/condition_parser/actor.rs +++ b/dar2oar_core/src/condition_parser/actor.rs @@ -96,7 +96,7 @@ mod tests { let condition_name = "IsActorBase"; let args = vec![FnArg::PluginValue { plugin_name: "Skyrim.esm", - form_id: NumberLiteral::Hex(0x00000007), + form_id: NumberLiteral::Hex(0x0000_0007), }]; let is_negated = true; diff --git a/dar2oar_core/src/condition_parser/compare.rs b/dar2oar_core/src/condition_parser/compare.rs index 27bbc2b..2bf4f3b 100644 --- a/dar2oar_core/src/condition_parser/compare.rs +++ b/dar2oar_core/src/condition_parser/compare.rs @@ -43,8 +43,8 @@ pub(super) fn parse_compare( "ValueLessThan" => create_compare(Cmp::Lt), _ => { return Err(ParseError::UnexpectedValue( - "ValueEqualTo or ValueLessThan".to_string(), - condition_name.to_string(), + "ValueEqualTo or ValueLessThan".into(), + condition_name.into(), )) } }) diff --git a/dar2oar_core/src/condition_parser/conditions.rs b/dar2oar_core/src/condition_parser/conditions.rs index fc487ca..fdaa062 100644 --- a/dar2oar_core/src/condition_parser/conditions.rs +++ b/dar2oar_core/src/condition_parser/conditions.rs @@ -161,7 +161,7 @@ mod tests { fn_name: "IsActorBase", args: vec![FnArg::PluginValue { plugin_name: "Skyrim.esm", - form_id: NumberLiteral::Hex(0x00000007), + form_id: NumberLiteral::Hex(0x0000_0007), }], }; let player = Expression { diff --git a/dar2oar_core/src/condition_parser/dar_interface.rs b/dar2oar_core/src/condition_parser/dar_interface.rs index 190eca0..965cb82 100644 --- a/dar2oar_core/src/condition_parser/dar_interface.rs +++ b/dar2oar_core/src/condition_parser/dar_interface.rs @@ -20,9 +20,9 @@ pub enum ParseError { impl From for NumericLiteral { fn from(value: NumberLiteral) -> Self { match value { - NumberLiteral::Decimal(num) => NumericLiteral::Decimal(num), - NumberLiteral::Float(num) => NumericLiteral::Float(num), - NumberLiteral::Hex(num) => NumericLiteral::Hex(num), + NumberLiteral::Decimal(num) => Self::Decimal(num), + NumberLiteral::Float(num) => Self::Float(num), + NumberLiteral::Hex(num) => Self::Hex(num), } } } @@ -31,9 +31,9 @@ impl From<&NumberLiteral> for NumericLiteral { fn from(value: &NumberLiteral) -> Self { //! Note: omitting the definition using owned into will result in a circular loop. match *value { - NumberLiteral::Decimal(num) => NumericLiteral::Decimal(num), - NumberLiteral::Float(num) => NumericLiteral::Float(num), - NumberLiteral::Hex(num) => NumericLiteral::Hex(num), + NumberLiteral::Decimal(num) => Self::Decimal(num), + NumberLiteral::Float(num) => Self::Float(num), + NumberLiteral::Hex(num) => Self::Hex(num), } } } @@ -42,7 +42,7 @@ impl TryFrom> for NumericLiteral { type Error = ParseError; fn try_from(value: FnArg) -> Result { - NumericLiteral::try_from(&value) + Self::try_from(&value) } } @@ -100,7 +100,7 @@ impl TryFrom> for StaticValue { type Error = ParseError; fn try_from(value: FnArg) -> Result { - StaticValue::try_from(&value) + Self::try_from(&value) } } @@ -111,7 +111,7 @@ impl TryFrom<&FnArg<'_>> for StaticValue { match value { FnArg::Number(num) => Ok(num.into()), other @ FnArg::PluginValue { .. } => Err(ParseError::UnexpectedValue( - "StaticValue(e.g. 3.0)".to_string(), + "StaticValue(e.g. 3.0)".to_owned(), format!("{other:?}",), )), } diff --git a/dar2oar_core/src/condition_parser/macros.rs b/dar2oar_core/src/condition_parser/macros.rs index 68cbaab..5eaf397 100644 --- a/dar2oar_core/src/condition_parser/macros.rs +++ b/dar2oar_core/src/condition_parser/macros.rs @@ -12,9 +12,9 @@ pub(super) trait GetArg { /// /// Use [Generic Associated Types(GATs)](https://blog.rust-lang.org/2022/10/28/gats-stabilization.html#what-are-gats) /// for the `&T` in [`Vec`] because it has the same lifeTime as [Vec]. - type Output<'a> + type Output<'this> where - Self: 'a; + Self: 'this; /// Access the element at the specified index of the vector. /// @@ -30,27 +30,24 @@ pub(super) trait GetArg { /// A result containing a reference to the desired element or a `Error` with detailed information if the index is out of bounds. fn try_get_real(&self, index: usize, expected: T, actual: T) -> Self::Output<'_> where - T: ToString; + T: Into; } impl GetArg for Vec> { - type Output<'a> = Result<&'a FnArg<'a>, ParseError> where Self: 'a; + type Output<'this> = Result<&'this FnArg<'this>, ParseError> where Self: 'this; fn try_get(&self, index: usize, expected: impl ToString) -> Self::Output<'_> { - self.get(index).ok_or(ParseError::UnexpectedValue( - expected.to_string(), - format!("None in args[{}]", index), - )) + self.get(index).ok_or_else(|| { + ParseError::UnexpectedValue(expected.to_string(), format!("None in args[{index}]")) + }) } fn try_get_real(&self, index: usize, expected: T, actual: T) -> Self::Output<'_> where - T: ToString, + T: Into, { - self.get(index).ok_or(ParseError::UnexpectedValue( - expected.to_string(), - actual.to_string(), - )) + self.get(index) + .ok_or_else(|| ParseError::UnexpectedValue(expected.into(), actual.into())) } } diff --git a/dar2oar_core/src/conditions/faction_rank.rs b/dar2oar_core/src/conditions/faction_rank.rs index cf7c951..3d4dda1 100644 --- a/dar2oar_core/src/conditions/faction_rank.rs +++ b/dar2oar_core/src/conditions/faction_rank.rs @@ -102,7 +102,7 @@ mod tests { let expected = FactionRank { faction: PluginValue { - plugin_name: "".into(), + plugin_name: String::new(), form_id: "".into(), }, comparison: Cmp::Eq, diff --git a/dar2oar_core/src/conditions/namespace_config.rs b/dar2oar_core/src/conditions/namespace_config.rs index 342ef2f..8ae38f1 100644 --- a/dar2oar_core/src/conditions/namespace_config.rs +++ b/dar2oar_core/src/conditions/namespace_config.rs @@ -2,17 +2,17 @@ use serde::{Deserialize, Serialize}; /// Represents the configuration structure for the 'config.json' namespace. -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] -pub struct MainConfig<'a> { +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct MainConfig<'config> { /// The name associated with the configuration. #[serde(default)] - pub name: &'a str, + pub name: &'config str, /// The description associated with the configuration. #[serde(default)] - pub description: &'a str, + pub description: &'config str, /// The author associated with the configuration. #[serde(default)] - pub author: &'a str, + pub author: &'config str, } diff --git a/dar2oar_core/src/dar_syntax/error.rs b/dar2oar_core/src/dar_syntax/error.rs index 3b56a86..74bc6b5 100644 --- a/dar2oar_core/src/dar_syntax/error.rs +++ b/dar2oar_core/src/dar_syntax/error.rs @@ -16,16 +16,19 @@ pub fn convert_error>(input: I, e: VerboseErro for (i, (substring, kind)) in e.errors.iter().enumerate() { let offset = input.offset(substring); - if input.is_empty() { + // Safety: + // [`Result`] to this variable does not return `Err`, + // Because `write!` to a `String` is infallible, this `unwrap` is fine. + let _ = if input.is_empty() { match kind { VerboseErrorKind::Char(c) => { - write!(&mut result, "{}: expected '{}', got empty input\n\n", i, c) + write!(&mut result, "{i}: expected '{c}', got empty input\n\n") } VerboseErrorKind::Context(s) => { - write!(&mut result, "{}: in {}, got empty input\n\n", i, s) + write!(&mut result, "{i}: in {s}, got empty input\n\n") } VerboseErrorKind::Nom(e) => { - write!(&mut result, "{}: in {:?}, got empty input\n\n", i, e) + write!(&mut result, "{i}: in {e:?}, got empty input\n\n") } } } else { @@ -110,10 +113,7 @@ pub fn convert_error>(input: I, e: VerboseErro column = column_number, ), } - } - .expect( - "Unreachable, Because `write!` to a `String` is infallible, this `unwrap` is fine.", - ); + }; } result diff --git a/dar2oar_core/src/dar_syntax/syntax.rs b/dar2oar_core/src/dar_syntax/syntax.rs index 6886d38..db6e15b 100644 --- a/dar2oar_core/src/dar_syntax/syntax.rs +++ b/dar2oar_core/src/dar_syntax/syntax.rs @@ -53,11 +53,11 @@ use std::fmt; /// - Plugin e.g. Skyrim.esm | 0x007 /// - Literal e.g. 1.0 #[derive(Debug, Clone, PartialEq)] -pub enum FnArg<'a> { +pub enum FnArg<'input> { /// e.g. "Skyrim.esm" | 0x007 PluginValue { /// e.g. "Skyrim.esm" - plugin_name: &'a str, + plugin_name: &'input str, /// e.g. 1 form_id: NumberLiteral, }, @@ -91,26 +91,26 @@ pub enum NumberLiteral { impl fmt::Display for NumberLiteral { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - NumberLiteral::Hex(hex) => write!(f, "0x{hex:x}"), - NumberLiteral::Decimal(decimal) => write!(f, "{decimal}"), - NumberLiteral::Float(float) => write!(f, "{float}"), + Self::Hex(hex) => write!(f, "0x{hex:x}"), + Self::Decimal(decimal) => write!(f, "{decimal}"), + Self::Float(float) => write!(f, "{float}"), } } } /// DAR One line representation #[derive(Debug, Clone, PartialEq)] -pub struct Expression<'a> { +pub struct Expression<'input> { /// not condition pub negated: bool, /// function name == condition name - pub fn_name: &'a str, + pub fn_name: &'input str, /// arguments - pub args: Vec>, + pub args: Vec>, } /// AND | OR -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Operator { /// AND And, @@ -120,21 +120,21 @@ pub enum Operator { /// Represents a high-level condition, which can be an AND combination, OR combination, or a leaf expression. #[derive(Debug, Clone, PartialEq)] -pub enum Condition<'a> { +pub enum Condition<'input> { /// Represents an AND combination of multiple conditions. - And(Vec>), + And(Vec>), /// Represents an OR combination of multiple conditions. - Or(Vec>), + Or(Vec>), /// Represents a leaf expression within the condition hierarchy. - Exp(Expression<'a>), + Exp(Expression<'input>), } -impl<'a> Condition<'a> { +impl<'input> Condition<'input> { /// push to inner vec /// /// # panics /// If push to [`Self::Exp`] - fn push(&mut self, expression: Condition<'a>) { + fn push(&mut self, expression: Condition<'input>) { match self { Condition::And(inner) | Condition::Or(inner) => inner.push(expression), Condition::Exp(_) => panic!("Expression cannot push"), @@ -143,7 +143,7 @@ impl<'a> Condition<'a> { } /// Type alias for a result type using [`nom::IResult`], wrapping potential errors with [`nom::error::VerboseError`] -type IResult<'a, I, O, E = nom::error::VerboseError<&'a str>> = nom::IResult; +type IResult<'input, I, O, E = nom::error::VerboseError<&'input str>> = nom::IResult; use nom::error::ParseError; // To use from_error_kind /// A macro for returning an error with a specific error kind in the `nom::error::VerboseError` variant. @@ -503,7 +503,7 @@ NOT IsActorValueLessThan(30, 60) fn_name: "IsActorBase", args: vec![FnArg::PluginValue { plugin_name: "Skyrim.esm", - form_id: NumberLiteral::Hex(0x00BCDEF7), + form_id: NumberLiteral::Hex(0x00BC_DEF7), }], }; let player = Expression { @@ -538,7 +538,7 @@ NOT IsActorValueLessThan(30, 60) fn_name: "IsActorBase", args: vec![FnArg::PluginValue { plugin_name: "Skyrim.esm", - form_id: NumberLiteral::Hex(0x00000007), + form_id: NumberLiteral::Hex(0x0000_0007), }], })]); assert_eq!(parse_condition(input), Ok(("", expected))); @@ -552,7 +552,7 @@ NOT IsActorValueLessThan(30, 60) fn_name: "IsActorBase", args: vec![FnArg::PluginValue { plugin_name: "Skyrim.esm", - form_id: NumberLiteral::Hex(0x00000007), + form_id: NumberLiteral::Hex(0x0000_0007), }], })])]); @@ -567,7 +567,7 @@ NOT IsActorValueLessThan(30, 60) fn_name: "IsActorBase", args: vec![FnArg::PluginValue { plugin_name: "Skyrim.esm", - form_id: NumberLiteral::Hex(0x00000007), + form_id: NumberLiteral::Hex(0x0000_0007), }], })]); diff --git a/dar2oar_core/src/fs/converter/common.rs b/dar2oar_core/src/fs/converter/common.rs index 41c6822..67cacd4 100644 --- a/dar2oar_core/src/fs/converter/common.rs +++ b/dar2oar_core/src/fs/converter/common.rs @@ -23,28 +23,27 @@ where { let path = path.as_ref(); let ConvertOptions { - dar_dir: _, oar_dir, mod_name, author, section_table, section_1person_table, - run_parallel: _, hide_dar, + .. } = options; let ParsedPath { - dar_root: _, oar_root, is_1st_person, mod_name: parsed_mod_name, priority, remain_dir, + .. } = parsed_path; let mut parsed_mod_name = mod_name .as_deref() - .unwrap_or(parsed_mod_name.as_deref().unwrap_or("Unknown")) + .unwrap_or_else(|| parsed_mod_name.as_deref().unwrap_or("Unknown")) .to_owned(); if *is_1st_person { parsed_mod_name.push_str("_1st_person"); @@ -52,13 +51,12 @@ where let oar_name_space = oar_dir .as_deref() - .map(|oar_mod_root| match is_1st_person { + .map_or(oar_root.clone(), |oar_mod_root| match is_1st_person { true => Path::new(oar_mod_root) .join("meshes/actors/character/_1stperson/animations/OpenAnimationReplacer"), false => Path::new(oar_mod_root) .join("meshes/actors/character/animations/OpenAnimationReplacer"), }) - .unwrap_or(oar_root.clone()) .join(&parsed_mod_name); let file_name = path diff --git a/dar2oar_core/src/fs/converter/support_cmd.rs b/dar2oar_core/src/fs/converter/support_cmd.rs index 93e550c..ad7be0d 100644 --- a/dar2oar_core/src/fs/converter/support_cmd.rs +++ b/dar2oar_core/src/fs/converter/support_cmd.rs @@ -86,7 +86,7 @@ pub async fn remove_oar( let paths: Vec<&OsStr> = path.iter().collect(); if let Some(oar_dir) = paths - .get(0..oar_start_idx + 1) + .get(0..=oar_start_idx) .map(|str_paths| str_paths.join(OsStr::new("/"))) { if prev_dir == oar_dir { @@ -145,7 +145,7 @@ mod test { #[tokio::test] async fn should_unhide_dar_files() -> Result<()> { - let _guard = init_tracing("unhide_dar", tracing::Level::DEBUG)?; + let _guard = init_tracing("unhide_dar", tracing::Level::ERROR)?; let temp_dir = TempDir::new()?; let test_dir = temp_dir @@ -160,7 +160,7 @@ mod test { #[tokio::test] async fn should_remove_oar_dir() -> Result<()> { - let _guard = init_tracing("remove_oar", tracing::Level::DEBUG)?; + let _guard = init_tracing("remove_oar", tracing::Level::ERROR)?; let temp_dir = TempDir::new()?; let test_dir = temp_dir diff --git a/dar2oar_core/src/fs/mapping_table.rs b/dar2oar_core/src/fs/mapping_table.rs index 2d79716..b10d682 100644 --- a/dar2oar_core/src/fs/mapping_table.rs +++ b/dar2oar_core/src/fs/mapping_table.rs @@ -59,7 +59,7 @@ fn parse_mapping_table(table: &str) -> HashMap { let section_name = match mapping.1 { None => { idx += 1; - format!("{}_{}", current_section_name, idx) + format!("{current_section_name}_{idx}") } Some(val) => { current_section_name = val.trim(); @@ -84,7 +84,7 @@ mod tests { #[test] fn test_parse_mapping_table() { - let input = r#" + let input = " 8000000 Combat 8000001 8000001 Base @@ -97,7 +97,7 @@ mod tests { 8001010 8001010 Sword 8001020 -8001020 Sword+Shield"#; +8001020 Sword+Shield"; let result = parse_mapping_table(input); diff --git a/dar2oar_core/src/fs/path_changer.rs b/dar2oar_core/src/fs/path_changer.rs index 30d1262..4126e19 100644 --- a/dar2oar_core/src/fs/path_changer.rs +++ b/dar2oar_core/src/fs/path_changer.rs @@ -135,7 +135,7 @@ mod test { ); assert_eq!(is_1st_person, true); assert_eq!(mod_name, Some("ModName".to_string())); - assert_eq!(priority, Ok(8107000)); + assert_eq!(priority, Ok(8_107_000)); assert_eq!(remain_dir, None); Ok(()) } @@ -165,7 +165,7 @@ mod test { ); assert_eq!(is_1st_person, false); assert_eq!(mod_name, Some("ModName".to_string())); - assert_eq!(priority, Ok(8107000)); + assert_eq!(priority, Ok(8_107_000)); assert_eq!(remain_dir, Some(Path::new("InnerDir").to_path_buf())); Ok(()) } diff --git a/dar2oar_core/src/lib.rs b/dar2oar_core/src/lib.rs index c9ebb26..deb127c 100644 --- a/dar2oar_core/src/lib.rs +++ b/dar2oar_core/src/lib.rs @@ -1,93 +1,22 @@ +#![deny(clippy::all, clippy::nursery, clippy::cargo)] +#![allow( + clippy::derive_partial_eq_without_eq, + clippy::future_not_send, + clippy::multiple_crate_versions, + clippy::pub_with_shorthand, + clippy::redundant_pub_crate +)] +// See: https://rust-lang.github.io/rust-clippy/rust-1.75.0/index.html#/?groups=restriction #![deny( - clippy::all, - clippy::await_holding_lock, - clippy::char_lit_as_u8, - clippy::checked_conversions, - clippy::cognitive_complexity, - clippy::dbg_macro, - clippy::debug_assert_with_mut_call, - clippy::doc_link_with_quotes, - clippy::doc_markdown, - clippy::empty_enum, - clippy::empty_line_after_outer_attr, - clippy::empty_structs_with_brackets, - clippy::enum_glob_use, - clippy::exit, - clippy::expl_impl_clone_on_copy, - clippy::explicit_deref_methods, - clippy::explicit_into_iter_loop, - clippy::fallible_impl_from, - clippy::filter_map_next, - clippy::flat_map_option, - clippy::float_cmp, - clippy::float_cmp_const, - clippy::float_equality_without_abs, - clippy::fn_params_excessive_bools, - clippy::from_iter_instead_of_collect, - clippy::if_let_mutex, - clippy::implicit_clone, - clippy::imprecise_flops, - clippy::inefficient_to_string, - clippy::invalid_upcast_comparisons, - clippy::items_after_test_module, - clippy::large_digit_groups, - clippy::large_stack_arrays, - clippy::large_types_passed_by_value, - clippy::let_unit_value, - clippy::linkedlist, - clippy::lossy_float_literal, - clippy::macro_use_imports, - clippy::manual_ok_or, - clippy::map_err_ignore, - clippy::map_flatten, - clippy::map_unwrap_or, - clippy::match_on_vec_items, - clippy::match_same_arms, - clippy::match_wild_err_arm, - clippy::match_wildcard_for_single_variants, - clippy::mem_forget, - clippy::mismatched_target_os, - clippy::missing_const_for_fn, - clippy::missing_docs_in_private_items, - clippy::missing_enforced_import_renames, - clippy::missing_errors_doc, - clippy::missing_panics_doc, - clippy::mut_mut, - clippy::mutex_integer, - clippy::needless_borrow, - clippy::needless_continue, - clippy::needless_for_each, - clippy::option_if_let_else, - clippy::option_option, - clippy::path_buf_push_overwrite, - clippy::print_stderr, - clippy::print_stdout, - clippy::ptr_as_ptr, - clippy::rc_mutex, - clippy::ref_option_ref, - clippy::rest_pat_in_fully_bound_structs, - clippy::same_functions_in_if_condition, - clippy::semicolon_if_nothing_returned, - clippy::single_match_else, - clippy::string_add, - clippy::string_add_assign, - clippy::string_lit_as_bytes, - clippy::string_to_string, - clippy::suspicious_operation_groupings, - clippy::todo, - clippy::trait_duplication_in_bounds, - clippy::unimplemented, - clippy::unnested_or_patterns, - clippy::unseparated_literal_suffix, - clippy::unused_self, - clippy::unwrap_used, - clippy::used_underscore_binding, - clippy::useless_let_if_seq, - clippy::useless_transmute, - clippy::verbose_file_reads, - clippy::wildcard_dependencies, - clippy::wildcard_imports, - clippy::zero_sized_map_values + clippy::allow_attributes_without_reason, + clippy::clone_on_ref_ptr, + clippy::disallowed_script_idents, + clippy::error_impl_error, + clippy::expect_used, + clippy::filetype_is_file, +clippy::fn_to_numeric_cast_any, + + clippy::unwrap_in_result )] // See: https://rust-unofficial.github.io/patterns/anti_patterns/deny-warnings.html#alternatives #![deny( diff --git a/dar2oar_core/src/values/actor_value.rs b/dar2oar_core/src/values/actor_value.rs index f1364fd..91db7a8 100644 --- a/dar2oar_core/src/values/actor_value.rs +++ b/dar2oar_core/src/values/actor_value.rs @@ -25,7 +25,7 @@ pub struct ActorValue { /// - Actor Value Percentage (0-1) => "Percentage" /// /// default: `ActorValue` -#[derive(Debug, Clone, Default, PartialEq)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub enum ActorValueType { /// Value #[default] @@ -42,13 +42,13 @@ impl TryFrom<&str> for ActorValueType { type Error = &'static str; fn try_from(value: &str) -> Result { - match value { - "Value" => Ok(ActorValueType::ActorValue), - "Base" => Ok(ActorValueType::Base), - "Max" => Ok(ActorValueType::Max), - "Percentage" => Ok(ActorValueType::Percentage), - _ => Err("Invalid actor value type"), - } + Ok(match value { + "Value" => Self::ActorValue, + "Base" => Self::Base, + "Max" => Self::Max, + "Percentage" => Self::Percentage, + _ => return Err("Invalid actor value type"), + }) } } @@ -116,13 +116,13 @@ mod tests { fn test_serialize() -> Result<()> { let value = ActorValueType::Max; let result = serde_json::to_string(&value)?; - assert_eq!(result, "\"Max\""); + assert_eq!(result, r#""Max""#); Ok(()) } #[test] fn test_deserialize_valid() -> Result<()> { - let json = "\"Percentage\""; + let json = r#""Percentage""#; let result: ActorValueType = serde_json::from_str(json)?; assert_eq!(result, ActorValueType::Percentage); Ok(()) @@ -130,7 +130,7 @@ mod tests { #[test] fn test_deserialize_invalid() { - let json = "\"InvalidType\""; + let json = r#""InvalidType""#; let result: Result = serde_json::from_str(json); assert!(result.is_err()); } diff --git a/dar2oar_core/src/values/comparison.rs b/dar2oar_core/src/values/comparison.rs index 8997614..616d043 100644 --- a/dar2oar_core/src/values/comparison.rs +++ b/dar2oar_core/src/values/comparison.rs @@ -9,7 +9,7 @@ use std::fmt; /// - Lt: Less than("<") /// - Ge: Greater than or equal(">=") /// - Le: Lesser than or equal("<="), -#[derive(Debug, Clone, Default, PartialEq)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub enum Cmp { #[default] /// Equal("==") @@ -30,12 +30,12 @@ pub enum Cmp { impl fmt::Display for Cmp { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Cmp::Eq => write!(f, "=="), - Cmp::Ne => write!(f, "!="), - Cmp::Gt => write!(f, ">"), - Cmp::Lt => write!(f, "<"), - Cmp::Ge => write!(f, ">="), - Cmp::Le => write!(f, "<="), + Self::Eq => write!(f, "=="), + Self::Ne => write!(f, "!="), + Self::Gt => write!(f, ">"), + Self::Lt => write!(f, "<"), + Self::Ge => write!(f, ">="), + Self::Le => write!(f, "<="), } } } @@ -46,12 +46,12 @@ impl TryFrom<&str> for Cmp { fn try_from(value: &str) -> Result { Ok(match value { - "==" => Cmp::Eq, - "!=" => Cmp::Ne, - ">" => Cmp::Gt, - "<" => Cmp::Lt, - ">=" => Cmp::Ge, - "<=" => Cmp::Le, + "==" => Self::Eq, + "!=" => Self::Ne, + ">" => Self::Gt, + "<" => Self::Lt, + ">=" => Self::Ge, + "<=" => Self::Le, _ => { return Err( "Invalid comparison operator. Expected '==', '!=', '>', '<', '>=' or '<='", diff --git a/dar2oar_core/src/values/direction_value.rs b/dar2oar_core/src/values/direction_value.rs index 3dd4f5d..b1e6c73 100644 --- a/dar2oar_core/src/values/direction_value.rs +++ b/dar2oar_core/src/values/direction_value.rs @@ -1,5 +1,5 @@ //! Actor's Direction -use serde::de::{Error, Visitor}; +use serde::de::{Error, Unexpected, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::Value; @@ -31,18 +31,18 @@ impl TryFrom for Direction { fn try_from(value: u64) -> Result { Ok(match value { - 0 => Direction::None, - 1 => Direction::Forward, - 2 => Direction::Right, - 3 => Direction::Back, - 4 => Direction::Left, + 0 => Self::None, + 1 => Self::Forward, + 2 => Self::Right, + 3 => Self::Back, + 4 => Self::Left, _ => return Err("Invalid value for Direction"), }) } } impl From<&Direction> for f64 { - fn from(value: &Direction) -> f64 { + fn from(value: &Direction) -> Self { match *value { Direction::None => 0.0, Direction::Forward => 1.0, @@ -101,28 +101,25 @@ impl<'de> Deserialize<'de> for Direction { let value: Value = Deserialize::deserialize(deserializer)?; match value { Value::Number(num) => { - let direction = num - .as_u64() - .unwrap_or(num.as_f64().ok_or(Error::invalid_type( - serde::de::Unexpected::Other("WeaponType parse f64"), - &"a valid f64", - ))? as u64); - let direction = Direction::try_from(direction).map_err(|err| { - Error::invalid_type(serde::de::Unexpected::Other(err), &"a valid u64 or f64") - })?; + let err = || { + Error::invalid_type(Unexpected::Other("WeaponType parse f64"), &"a valid f64") + }; + let direction = num.as_u64().unwrap_or(num.as_f64().ok_or_else(err)? as u64); + let err = |err| Error::invalid_type(Unexpected::Other(err), &"a valid u64 or f64"); + let direction = Self::try_from(direction).map_err(err)?; Ok(direction) } Value::String(s) => { let t = s.parse::().map_err(|_err| { Error::invalid_type( - serde::de::Unexpected::Other("Couldn't parse float value"), + Unexpected::Other("Couldn't parse float value"), &"a valid Direction value", ) })?; DirectionVisitor.visit_f64(t) } _ => Err(Error::invalid_type( - serde::de::Unexpected::Other("not a valid value for Direction"), + Unexpected::Other("not a valid value for Direction"), &"a valid Direction value", )), } diff --git a/dar2oar_core/src/values/form_value.rs b/dar2oar_core/src/values/form_value.rs index 878fd46..56ff5d4 100644 --- a/dar2oar_core/src/values/form_value.rs +++ b/dar2oar_core/src/values/form_value.rs @@ -3,7 +3,7 @@ use super::PluginValue; use serde::{Deserialize, Serialize}; /// Wrapper for wrapping pluginValue with a key called `form` -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct FormValue { /// A combination of the plugin name and the ID in it. pub form: PluginValue, diff --git a/dar2oar_core/src/values/graph_value.rs b/dar2oar_core/src/values/graph_value.rs index 27e086e..98ce5bb 100644 --- a/dar2oar_core/src/values/graph_value.rs +++ b/dar2oar_core/src/values/graph_value.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Pair str & Int | Float | Bool -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct GraphValue { /// string /// @@ -15,7 +15,7 @@ pub struct GraphValue { } /// Float | Int | Bool -#[derive(Debug, Clone, Default, PartialEq)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub enum GraphVariableType { /// Floating point number #[default] @@ -32,9 +32,9 @@ impl Serialize for GraphVariableType { S: Serializer, { let type_str = match self { - GraphVariableType::Float => "Float", - GraphVariableType::Int => "Int", - GraphVariableType::Bool => "Bool", + Self::Float => "Float", + Self::Int => "Int", + Self::Bool => "Bool", }; serializer.serialize_str(type_str) } @@ -46,12 +46,12 @@ impl<'de> Deserialize<'de> for GraphVariableType { D: Deserializer<'de>, { let type_str = String::deserialize(deserializer)?; - match type_str.as_str() { - "Float" => Ok(GraphVariableType::Float), - "Int" => Ok(GraphVariableType::Int), - "Bool" => Ok(GraphVariableType::Bool), - _ => Err(serde::de::Error::custom("Invalid graph variable type")), - } + Ok(match type_str.as_str() { + "Float" => Self::Float, + "Int" => Self::Int, + "Bool" => Self::Bool, + _ => return Err(serde::de::Error::custom("Invalid graph variable type")), + }) } } diff --git a/dar2oar_core/src/values/keyword_value.rs b/dar2oar_core/src/values/keyword_value.rs index aae438c..b6c1e56 100644 --- a/dar2oar_core/src/values/keyword_value.rs +++ b/dar2oar_core/src/values/keyword_value.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; /// Trigger keywords -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] #[serde(untagged)] pub enum Keyword { /// Single numeric type @@ -33,14 +33,14 @@ impl<'de> Deserialize<'de> for Keyword { Ok(keyword) => keyword, Err(err) => return Err(serde::de::Error::custom(err)), }; - Ok(Keyword::Literal(keyword_value)) + Ok(Self::Literal(keyword_value)) } else if map.contains_key("form") { // If both "pluginName" and "formID" fields are present, assume it's a Form let form_value: FormValue = match serde_json::from_value(value) { Ok(form) => form, Err(err) => return Err(serde::de::Error::custom(err)), }; - Ok(Keyword::Form(form_value)) + Ok(Self::Form(form_value)) } else { Err(serde::de::Error::custom( "Unable to determine Keyword variant", diff --git a/dar2oar_core/src/values/literal_value.rs b/dar2oar_core/src/values/literal_value.rs index da5f1f4..91506ca 100644 --- a/dar2oar_core/src/values/literal_value.rs +++ b/dar2oar_core/src/values/literal_value.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; /// Wrapper `editor_id` -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct LiteralValue { /// Editor ID #[serde(rename = "editorID")] diff --git a/dar2oar_core/src/values/numeric_literal.rs b/dar2oar_core/src/values/numeric_literal.rs index 2069691..607e993 100644 --- a/dar2oar_core/src/values/numeric_literal.rs +++ b/dar2oar_core/src/values/numeric_literal.rs @@ -22,19 +22,19 @@ pub enum NumericLiteral { impl From for NumericLiteral { fn from(value: usize) -> Self { - NumericLiteral::Hex(value) + Self::Hex(value) } } impl From for NumericLiteral { fn from(value: isize) -> Self { - NumericLiteral::Decimal(value) + Self::Decimal(value) } } impl From for NumericLiteral { fn from(value: f32) -> Self { - NumericLiteral::Float(value) + Self::Float(value) } } @@ -48,9 +48,9 @@ impl fmt::Display for NumericLiteral { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { // NOTE: When converted to a string, omit the hexadecimal prefix (0x) and use the same hex notation as for OAR. - NumericLiteral::Hex(hex) => write!(f, "{hex:x}"), - NumericLiteral::Decimal(decimal) => write!(f, "{decimal}"), - NumericLiteral::Float(float) => write!(f, "{float}"), + Self::Hex(hex) => write!(f, "{hex:x}"), + Self::Decimal(decimal) => write!(f, "{decimal}"), + Self::Float(float) => write!(f, "{float}"), } } } @@ -61,9 +61,9 @@ impl Serialize for NumericLiteral { S: Serializer, { match self { - NumericLiteral::Hex(hex) => serializer.serialize_str(&format!("{:x}", hex)), // NOTE: OAR non prefix(0x) - NumericLiteral::Decimal(decimal) => serializer.serialize_i64(*decimal as i64), - NumericLiteral::Float(float) => serializer.serialize_f32(*float), + Self::Hex(hex) => serializer.serialize_str(&format!("{hex:x}")), // NOTE: OAR non prefix(0x) + Self::Decimal(decimal) => serializer.serialize_i64(*decimal as i64), + Self::Float(float) => serializer.serialize_f32(*float), } } } @@ -91,7 +91,7 @@ impl<'de> Deserialize<'de> for NumericLiteral { // Parse hexadecimal value let hex_value = value.trim_start_matches("0x"); usize::from_str_radix(hex_value, 16).map_or_else( - |_err| Err(E::custom(format!("Invalid hexadecimal value: {}", value))), + |_err| Err(E::custom(format!("Invalid hexadecimal value: {value}"))), |hex| Ok(NumericLiteral::Hex(hex)), ) } else if let Ok(decimal) = value.parse::() { @@ -99,7 +99,7 @@ impl<'de> Deserialize<'de> for NumericLiteral { } else if let Ok(float) = value.parse::() { Ok(NumericLiteral::Float(float)) } else { - Err(E::custom(format!("Invalid numeric value: {}", value))) + Err(E::custom(format!("Invalid numeric value: {value}"))) } } } @@ -109,7 +109,7 @@ impl<'de> Deserialize<'de> for NumericLiteral { Value::Number(num) => NumericLiteralVisitor.visit_str(num.to_string().as_str()), Value::String(s) => NumericLiteralVisitor.visit_str(s.as_str()), _ => Err(serde::de::Error::invalid_type( - serde::de::Unexpected::Other(format!("Invalid numeric value: {}", value).as_str()), + serde::de::Unexpected::Other(format!("Invalid numeric value: {value}").as_str()), &"a string, integer, or floating-point number", )), } diff --git a/dar2oar_core/src/values/numeric_value.rs b/dar2oar_core/src/values/numeric_value.rs index 821f0f3..e5c8745 100644 --- a/dar2oar_core/src/values/numeric_value.rs +++ b/dar2oar_core/src/values/numeric_value.rs @@ -44,15 +44,15 @@ impl<'de> Deserialize<'de> for NumericValue { if map.contains_key("value") { // If the "value" field is present, assume it's a StaticValue let static_value: StaticValue = deserialize_json!(value)?; - Ok(NumericValue::StaticValue(static_value)) + Ok(Self::StaticValue(static_value)) } else if map.contains_key("form") { let global_variable = deserialize_json!(value)?; - Ok(NumericValue::GlobalVariable(global_variable)) + Ok(Self::GlobalVariable(global_variable)) } else if map.contains_key("actorValue") { let actor_value: ActorValue = deserialize_json!(value)?; - Ok(NumericValue::ActorValue(actor_value)) + Ok(Self::ActorValue(actor_value)) } else if map.contains_key("graphValue") { - Ok(NumericValue::GraphVariable(deserialize_json!(value)?)) + Ok(Self::GraphVariable(deserialize_json!(value)?)) } else { Err(serde::de::Error::custom( "Unable to determine NumericValue variant", diff --git a/dar2oar_core/src/values/plugin_value.rs b/dar2oar_core/src/values/plugin_value.rs index 3ea6f08..aeee866 100644 --- a/dar2oar_core/src/values/plugin_value.rs +++ b/dar2oar_core/src/values/plugin_value.rs @@ -4,7 +4,7 @@ use compact_str::CompactString; use serde::{Deserialize, Serialize}; /// A combination of the plugin name and the ID in it. -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct PluginValue { /// e.g. `Skyrim.esm` #[serde(rename = "pluginName")] @@ -30,7 +30,7 @@ pub struct PluginValue { } /// Non prefix(0x) hexadecimal ID -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct FormID(CompactString); impl From<&str> for FormID { @@ -59,14 +59,11 @@ from!(usize, isize, f32); impl From for FormID { fn from(value: NumericLiteral) -> Self { Self(match value { - NumericLiteral::Hex(hex_value) => format!("{:x}", hex_value).into(), - NumericLiteral::Decimal(decimal_value) => { - if decimal_value == 0 { - CompactString::default() - } else { - format!("{:x}", decimal_value).into() - } - } + NumericLiteral::Hex(hex_value) => format!("{hex_value:x}").into(), + NumericLiteral::Decimal(decimal_value) => match decimal_value == 0 { + true => CompactString::default(), + false => format!("{decimal_value:x}").into(), + }, NumericLiteral::Float(float_value) => format!("{:x}", float_value as usize).into(), }) } @@ -117,7 +114,7 @@ mod tests { let default_plugin_value = PluginValue::default(); let expected = PluginValue { - plugin_name: "".into(), + plugin_name: String::new(), form_id: "".into(), }; diff --git a/dar2oar_core/src/values/static_value.rs b/dar2oar_core/src/values/static_value.rs index c96aea0..55455ae 100644 --- a/dar2oar_core/src/values/static_value.rs +++ b/dar2oar_core/src/values/static_value.rs @@ -23,6 +23,6 @@ pub struct StaticValue { impl From for StaticValue { fn from(value: f32) -> Self { - StaticValue { value } + Self { value } } } diff --git a/dar2oar_core/src/values/type_value.rs b/dar2oar_core/src/values/type_value.rs index 289a47d..15b2d33 100644 --- a/dar2oar_core/src/values/type_value.rs +++ b/dar2oar_core/src/values/type_value.rs @@ -6,14 +6,14 @@ use serde_json::Value; use super::NumericLiteral; /// Wrapper for [`WeaponType`] -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct TypeValue { /// Weapon type value pub value: WeaponType, } /// Weapon type enumeration -#[derive(Debug, Clone, Default, PartialEq)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub enum WeaponType { /// -1.0 Other = -1, @@ -63,26 +63,26 @@ impl TryFrom for WeaponType { fn try_from(value: i64) -> Result { Ok(match value { - -1 => WeaponType::Other, - 0 => WeaponType::Unarmed, - 1 => WeaponType::Sword, - 2 => WeaponType::Dagger, - 3 => WeaponType::WarAxe, - 4 => WeaponType::Mace, - 5 => WeaponType::Greatsword, - 6 => WeaponType::Battleaxe, - 7 => WeaponType::Bow, - 8 => WeaponType::Staff, - 9 => WeaponType::Crossbow, - 10 => WeaponType::Warhammer, - 11 => WeaponType::Shield, - 12 => WeaponType::AlterationSpell, - 13 => WeaponType::IllusionSpell, - 14 => WeaponType::DestructionSpell, - 15 => WeaponType::ConjurationSpell, - 16 => WeaponType::RestorationSpell, - 17 => WeaponType::Scroll, - 18 => WeaponType::Torch, + -1 => Self::Other, + 0 => Self::Unarmed, + 1 => Self::Sword, + 2 => Self::Dagger, + 3 => Self::WarAxe, + 4 => Self::Mace, + 5 => Self::Greatsword, + 6 => Self::Battleaxe, + 7 => Self::Bow, + 8 => Self::Staff, + 9 => Self::Crossbow, + 10 => Self::Warhammer, + 11 => Self::Shield, + 12 => Self::AlterationSpell, + 13 => Self::IllusionSpell, + 14 => Self::DestructionSpell, + 15 => Self::ConjurationSpell, + 16 => Self::RestorationSpell, + 17 => Self::Scroll, + 18 => Self::Torch, _ => return Err("Invalid value for WeaponType"), }) } @@ -111,26 +111,26 @@ impl TryFrom<&str> for WeaponType { fn try_from(value: &str) -> Result { Ok(match value { - "-1" | "-1.0" => WeaponType::Other, - "0" | "0.0" => WeaponType::Unarmed, - "1" | "1.0" => WeaponType::Sword, - "2" | "2.0" => WeaponType::Dagger, - "3" | "3.0" => WeaponType::WarAxe, - "4" | "4.0" => WeaponType::Mace, - "5" | "5.0" => WeaponType::Greatsword, - "6" | "6.0" => WeaponType::Battleaxe, - "7" | "7.0" => WeaponType::Bow, - "8" | "8.0" => WeaponType::Staff, - "9" | "9.0" => WeaponType::Crossbow, - "10" | "10.0" => WeaponType::Warhammer, - "11" | "11.0" => WeaponType::Shield, - "12" | "12.0" => WeaponType::AlterationSpell, - "13" | "13.0" => WeaponType::IllusionSpell, - "14" | "14.0" => WeaponType::DestructionSpell, - "15" | "15.0" => WeaponType::ConjurationSpell, - "16" | "16.0" => WeaponType::RestorationSpell, - "17" | "17.0" => WeaponType::Scroll, - "18" | "18.0" => WeaponType::Torch, + "-1" | "-1.0" => Self::Other, + "0" | "0.0" => Self::Unarmed, + "1" | "1.0" => Self::Sword, + "2" | "2.0" => Self::Dagger, + "3" | "3.0" => Self::WarAxe, + "4" | "4.0" => Self::Mace, + "5" | "5.0" => Self::Greatsword, + "6" | "6.0" => Self::Battleaxe, + "7" | "7.0" => Self::Bow, + "8" | "8.0" => Self::Staff, + "9" | "9.0" => Self::Crossbow, + "10" | "10.0" => Self::Warhammer, + "11" | "11.0" => Self::Shield, + "12" | "12.0" => Self::AlterationSpell, + "13" | "13.0" => Self::IllusionSpell, + "14" | "14.0" => Self::DestructionSpell, + "15" | "15.0" => Self::ConjurationSpell, + "16" | "16.0" => Self::RestorationSpell, + "17" | "17.0" => Self::Scroll, + "18" | "18.0" => Self::Torch, _ => return Err("Invalid value for WeaponType"), }) } @@ -210,16 +210,19 @@ impl<'de> Deserialize<'de> for WeaponType { let value: Value = Deserialize::deserialize(deserializer)?; match value { Value::Number(num) => { - let weapon = WeaponType::try_from(num.as_i64().unwrap_or(num.as_f64().ok_or( - Error::invalid_type( - serde::de::Unexpected::Other("WeaponType parse f64"), - &"a valid f64", - ), - )? - as i64)) - .map_err(|err| { - Error::invalid_type(serde::de::Unexpected::Other(err), &"a valid i64 or f64") - })?; + let weapon = + Self::try_from(num.as_i64().unwrap_or(num.as_f64().ok_or_else(|| { + Error::invalid_type( + serde::de::Unexpected::Other("WeaponType parse f64"), + &"a valid f64", + ) + })? as i64)) + .map_err(|err| { + Error::invalid_type( + serde::de::Unexpected::Other(err), + &"a valid i64 or f64", + ) + })?; Ok(weapon) } Value::String(s) => Ok(s.as_str().try_into().map_err(|_err| { diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 8f08570..024a45b 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -19,14 +19,14 @@ "incremental": true, "plugins": [ { - "name": "next" - } + "name": "next", + }, ], "paths": { - "@/*": ["./src/*"] + "@/*": ["./src/*"], }, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "../out/types/**/*.ts", ".next/types/**/*.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules"], } diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 43a8b6a..74a1717 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -3,6 +3,8 @@ name = "g_dar2oar" version.workspace = true description = "DAR to OAR Converter GUI" authors = ["SARDONYX-sard"] +categories.workspace = true +keywords = ["converter", "skyrim", "gui"] license = "MIT OR Apache-2.0" repository.workspace = true edition = "2021"