Skip to content

Commit

Permalink
Merge pull request ozkriff#662 from ozkriff/rust_1_53
Browse files Browse the repository at this point in the history
Fix new clippy::search_is_some lint
  • Loading branch information
ozkriff authored Jun 17, 2021
2 parents 7a5ee80 + 40ec0dd commit 2d221ee
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/core/battle/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,10 @@ fn extend_or_crate_sub_vec<T>(vec: &mut Vec<(Id, Vec<T>)>, id: Id, values: Vec<T
}
}

fn any_effect_with_id(effects: &[(Id, Vec<Effect>)], expected_id: Id) -> bool {
effects.iter().any(|(id, _)| id == &expected_id)
}

#[must_use]
#[derive(Default, Debug, PartialEq, Clone)]
struct ExecuteContext {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2d221ee

Please sign in to comment.