From c16d5fb4b46e823cbccea35a971e82d7b71af7f3 Mon Sep 17 00:00:00 2001 From: Yirmandias Date: Fri, 1 Sep 2023 16:02:39 +0200 Subject: [PATCH] clippy --- planning/planners/src/search/causal.rs | 2 +- .../src/chronicles/preprocessing/unused_effects.rs | 12 ++++-------- solver/src/core/state/domains.rs | 4 ++-- validator/src/procedures.rs | 10 ++-------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/planning/planners/src/search/causal.rs b/planning/planners/src/search/causal.rs index 4428964b..a67e84b9 100644 --- a/planning/planners/src/search/causal.rs +++ b/planning/planners/src/search/causal.rs @@ -76,7 +76,7 @@ impl SearchControl for ManualCausalSearch { .collect(); for &(tag, lig) in &self.encoding.tags { - let Tag::Support(cond, eff) = tag else {continue }; + let Tag::Support(cond, eff) = tag else { continue }; if !pending_conditions.contains(&cond) { continue; } diff --git a/planning/planning/src/chronicles/preprocessing/unused_effects.rs b/planning/planning/src/chronicles/preprocessing/unused_effects.rs index 0cda1f3d..927ffcf6 100644 --- a/planning/planning/src/chronicles/preprocessing/unused_effects.rs +++ b/planning/planning/src/chronicles/preprocessing/unused_effects.rs @@ -57,10 +57,8 @@ pub fn remove_unusable_effects(pb: &mut Problem) { } } - if num_removed > 0 { - if PRINT_PLANNER_OUTPUT.get() { - println!("Removed {num_removed} unusable effects"); - } + if num_removed > 0 && PRINT_PLANNER_OUTPUT.get() { + println!("Removed {num_removed} unusable effects"); } } @@ -126,9 +124,7 @@ pub fn merge_unusable_effects(pb: &mut Problem) { } } - if num_removed > 0 { - if PRINT_PLANNER_OUTPUT.get() { - println!("Merged {num_removed} unusable effects"); - } + if num_removed > 0 && PRINT_PLANNER_OUTPUT.get() { + println!("Merged {num_removed} unusable effects"); } } diff --git a/solver/src/core/state/domains.rs b/solver/src/core/state/domains.rs index d31a8283..14788529 100644 --- a/solver/src/core/state/domains.rs +++ b/solver/src/core/state/domains.rs @@ -70,11 +70,11 @@ impl Domains { self.implications.add_implication(from, to); if self.entails(from) { let prop_result = self.set_impl(to, DirectOrigin::ImplicationPropagation(from)); - assert!(matches!(prop_result, Ok(_)), "{}", "Inconsistency on the addition of implies({from:?}, {to:?}"); + assert!(prop_result.is_ok(), "{}", "Inconsistency on the addition of implies({from:?}, {to:?}"); } if self.entails(!to) { let prop_result = self.set_impl(!from, DirectOrigin::ImplicationPropagation(!to)); - assert!(matches!(prop_result, Ok(_)), "{}", "Inconsistency on the addition of implies({from:?}, {to:?}"); + assert!(prop_result.is_ok(), "{}", "Inconsistency on the addition of implies({from:?}, {to:?}"); } } diff --git a/validator/src/procedures.rs b/validator/src/procedures.rs index 49e391fd..6ecb4e3b 100644 --- a/validator/src/procedures.rs +++ b/validator/src/procedures.rs @@ -12,17 +12,11 @@ use anyhow::{bail, ensure, Context, Result}; pub type Procedure = fn(&Env, Vec) -> Result; pub fn and(env: &Env, args: Vec) -> Result { - args.iter().fold(Ok(true.into()), |r, a| match r { - Ok(b) => b & a.eval(env)?, - Err(e) => Err(e), - }) + args.iter().try_fold(true.into(), |b, a| b & a.eval(env)?) } pub fn or(env: &Env, args: Vec) -> Result { - args.iter().fold(Ok(false.into()), |r, a| match r { - Ok(b) => b | a.eval(env)?, - Err(e) => Err(e), - }) + args.iter().try_fold(false.into(), |b, a| b | a.eval(env)?) } pub fn not(env: &Env, args: Vec) -> Result {