From b2ef9b85a784e280054c883dcff1541c255e0753 Mon Sep 17 00:00:00 2001 From: jugeeya Date: Wed, 13 Dec 2023 17:52:54 -0800 Subject: [PATCH] Fix Clippy again (#657) * Fix clippy * More fixes * More fixes * More fixes * More fixes * More fixes * More fixes * More fixes * Fix test * More fixes --- src/common/consts.rs | 4 ++-- src/lib.rs | 1 + src/training/buff.rs | 2 +- src/training/ui/menu.rs | 8 ++++---- src/training/ui/mod.rs | 2 +- training_mod_tui/tests/test_stateful_list.rs | 2 +- training_mod_tui/tests/test_stateful_slider.rs | 2 +- training_mod_tui/tests/test_stateful_table.rs | 2 +- training_mod_tui/tests/test_submenu.rs | 5 +---- training_mod_tui/tests/test_toggle.rs | 2 +- 10 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/common/consts.rs b/src/common/consts.rs index bde25ff..e598410 100644 --- a/src/common/consts.rs +++ b/src/common/consts.rs @@ -9298,7 +9298,7 @@ fn character_pairs() -> [(i32, Character); 97] { fn get_parent_character(fighter: Character) -> Character { use Character::*; - return match fighter { + match fighter { Chrom => Roy, Daisy => Peach, Ken => Ryu, @@ -9308,7 +9308,7 @@ fn get_parent_character(fighter: Character) -> Character { Samusd => Samus, Wolf => Fox, //Pseudo-echo _ => fighter, - }; + } } pub fn kind_to_char(kind: i32) -> Character { diff --git a/src/lib.rs b/src/lib.rs index 8890177..72d7ab2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![feature(const_mut_refs)] #![feature(exclusive_range_pattern)] #![feature(c_variadic)] +#![allow(stable_features)] #![feature(pointer_byte_offsets)] #![allow( clippy::borrow_interior_mutable_const, diff --git a/src/training/buff.rs b/src/training/buff.rs index d5f04e3..da7987b 100644 --- a/src/training/buff.rs +++ b/src/training/buff.rs @@ -111,7 +111,7 @@ unsafe fn buff_hero(module_accessor: &mut app::BattleObjectModuleAccessor, statu set_buff_rem(module_accessor, buff_vec.len()); // Since it's the first step of buffing, we need to set up how many buffs there are } - if get_buff_rem(module_accessor) <= 0 { + if get_buff_rem(module_accessor) == 0 { // If there are no buffs selected/left, we're done if frame_counter::should_delay(3_u32, *BUFF_DELAY_COUNTER) { // Need to wait 3 frames to make sure we stop the spell SFX, since it's a bit delayed diff --git a/src/training/ui/menu.rs b/src/training/ui/menu.rs index 81c69fd..03ffc4c 100644 --- a/src/training/ui/menu.rs +++ b/src/training/ui/menu.rs @@ -583,7 +583,7 @@ pub unsafe fn draw(root_pane: &Pane) { // Left/Right tabs have keys if let Some(key) = key { - set_icon_text(icon_pane, &vec![**key]); + set_icon_text(icon_pane, &[**key]); } if *name == "CurrentTab" { @@ -604,7 +604,7 @@ pub unsafe fn draw(root_pane: &Pane) { .find_pane_by_name_recursive("set_txt_icon") .unwrap() .as_textbox(); - set_icon_text(icon_pane, &vec![*key.unwrap()]); + set_icon_text(icon_pane, &[*key.unwrap()]); key_help_pane .find_pane_by_name_recursive("set_txt_help") .unwrap() @@ -627,7 +627,7 @@ pub unsafe fn draw(root_pane: &Pane) { .find_pane_by_name_recursive("set_txt_icon") .unwrap() .as_textbox(); - set_icon_text(icon_pane, &vec![*key.unwrap()]); + set_icon_text(icon_pane, &[*key.unwrap()]); key_help_pane .find_pane_by_name_recursive("set_txt_help") .unwrap() @@ -645,7 +645,7 @@ pub unsafe fn draw(root_pane: &Pane) { // This is only displayed when you're in a multiple selection toggle menu w/ toggle.max > 1 let key = clear_toggle_key; let title = "Clear Toggle"; - set_icon_text(icon_pane.as_textbox(), &vec![*key.unwrap()]); + set_icon_text(icon_pane.as_textbox(), &[*key.unwrap()]); key_help_pane .find_pane_by_name_recursive("set_txt_help") .unwrap() diff --git a/src/training/ui/mod.rs b/src/training/ui/mod.rs index 2a6290f..1cc3055 100644 --- a/src/training/ui/mod.rs +++ b/src/training/ui/mod.rs @@ -18,7 +18,7 @@ mod input_log; pub mod menu; pub mod notifications; -pub unsafe fn set_icon_text(pane: &mut TextBox, icons: &Vec) { +pub unsafe fn set_icon_text(pane: &mut TextBox, icons: &[u16]) { pane.set_text_string(""); let it = pane.text_buf as *mut u16; diff --git a/training_mod_tui/tests/test_stateful_list.rs b/training_mod_tui/tests/test_stateful_list.rs index c766198..ff359ad 100644 --- a/training_mod_tui/tests/test_stateful_list.rs +++ b/training_mod_tui/tests/test_stateful_list.rs @@ -1,5 +1,5 @@ use ratatui::widgets::ListState; -use training_mod_tui_2::StatefulList; +use training_mod_tui::StatefulList; fn initialize_list(selected: Option) -> StatefulList { StatefulList { diff --git a/training_mod_tui/tests/test_stateful_slider.rs b/training_mod_tui/tests/test_stateful_slider.rs index 8acbed0..d9b6df8 100644 --- a/training_mod_tui/tests/test_stateful_slider.rs +++ b/training_mod_tui/tests/test_stateful_slider.rs @@ -1,4 +1,4 @@ -use training_mod_tui_2::{SliderState, StatefulSlider}; +use training_mod_tui::{SliderState, StatefulSlider}; fn initialize_slider(state: SliderState) -> StatefulSlider { StatefulSlider { diff --git a/training_mod_tui/tests/test_stateful_table.rs b/training_mod_tui/tests/test_stateful_table.rs index 3e4ad3b..8ba4e86 100644 --- a/training_mod_tui/tests/test_stateful_table.rs +++ b/training_mod_tui/tests/test_stateful_table.rs @@ -1,5 +1,5 @@ use ratatui::widgets::{TableSelection, TableState}; -use training_mod_tui_2::StatefulTable; +use training_mod_tui::StatefulTable; fn initialize_table(row: usize, col: usize) -> StatefulTable { let mut s = StatefulTable::with_items(2, 3, vec![0, 1, 2, 3, 4]); diff --git a/training_mod_tui/tests/test_submenu.rs b/training_mod_tui/tests/test_submenu.rs index a453d92..98c5b03 100644 --- a/training_mod_tui/tests/test_submenu.rs +++ b/training_mod_tui/tests/test_submenu.rs @@ -1,5 +1,5 @@ use ratatui::widgets::{TableSelection, TableState}; -use training_mod_tui_2::*; +use training_mod_tui::*; fn make_toggle<'a>(v: u8) -> Toggle<'a> { Toggle { @@ -55,9 +55,6 @@ fn initialize_submenu<'a>(submenu_type: SubMenuType) -> SubMenu<'a> { toggles: make_toggle_table_multiple(0, 0, 0), slider: Some(StatefulSlider::new()), }, - SubMenuType::None => { - panic!() - } } } diff --git a/training_mod_tui/tests/test_toggle.rs b/training_mod_tui/tests/test_toggle.rs index adb07f8..6b42e9c 100644 --- a/training_mod_tui/tests/test_toggle.rs +++ b/training_mod_tui/tests/test_toggle.rs @@ -1,4 +1,4 @@ -use training_mod_tui_2::Toggle; +use training_mod_tui::Toggle; #[test] fn toggle_serialize() {