From 40ec0dda8269d55ce93477319a2f94852b944673 Mon Sep 17 00:00:00 2001 From: Andrey Lesnikov Date: Thu, 17 Jun 2021 20:01:11 +0300 Subject: [PATCH] Fix new clippy::search_is_some lint --- src/core/battle/execute.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/core/battle/execute.rs b/src/core/battle/execute.rs index 456487a..797208b 100644 --- a/src/core/battle/execute.rs +++ b/src/core/battle/execute.rs @@ -638,6 +638,10 @@ fn extend_or_crate_sub_vec(vec: &mut Vec<(Id, Vec)>, id: Id, values: Vec)], expected_id: Id) -> bool { + effects.iter().any(|(id, _)| id == &expected_id) +} + #[must_use] #[derive(Default, Debug, PartialEq, Clone)] struct ExecuteContext { @@ -717,11 +721,7 @@ fn execute_use_ability_explode_fire( command: &command::UseAbility, ) -> ExecuteContext { let mut context = ExecuteContext::default(); - assert!(context - .instant_effects - .iter() - .position(|(id, _)| id == &command.id) - .is_none()); + assert!(!any_effect_with_id(&context.instant_effects, command.id)); let effects = vec![Effect::Vanish]; context.instant_effects.push((command.id, effects)); context.merge_with(start_fire(state, command.pos)); @@ -781,11 +781,7 @@ fn execute_use_ability_explode_poison( command: &command::UseAbility, ) -> ExecuteContext { let mut context = ExecuteContext::default(); - assert!(context - .instant_effects - .iter() - .position(|(id, _)| id == &command.id) - .is_none()); + assert!(!any_effect_with_id(&context.instant_effects, command.id)); let effects = vec![Effect::Vanish]; context.instant_effects.push((command.id, effects)); context.merge_with(create_poison_cloud(state, command.pos)); @@ -916,11 +912,7 @@ fn execute_use_ability_explode_damage( let effects = vec![wound_break_kill(state, id, damage, armor_break)]; context.instant_effects.push((id, effects)); } - assert!(context - .instant_effects - .iter() - .position(|(id, _)| id == &command.id) - .is_none()); + assert!(!any_effect_with_id(&context.instant_effects, command.id)); let effects = vec![Effect::Vanish]; context.instant_effects.push((command.id, effects)); context @@ -959,11 +951,7 @@ fn execute_use_ability_explode_push( } context.instant_effects.push((id, effects)); } - assert!(context - .instant_effects - .iter() - .position(|(id, _)| id == &command.id) - .is_none()); + assert!(!any_effect_with_id(&context.instant_effects, command.id)); let effects = vec![Effect::Vanish]; context.instant_effects.push((command.id, effects)); context