From 2da79bfdc6aca28394f22671329b8b4158bc1e44 Mon Sep 17 00:00:00 2001 From: oflatt Date: Fri, 27 Oct 2023 13:25:47 -0700 Subject: [PATCH] nits and typo --- src/explain.rs | 6 ++---- src/test.rs | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/explain.rs b/src/explain.rs index 41dd7c3f..15ddb037 100644 --- a/src/explain.rs +++ b/src/explain.rs @@ -241,7 +241,7 @@ impl Explanation { let mut seen_adjacent = Default::default(); let mut sum: ProofCost = Saturating(0); for e in self.explanation_trees.iter() { - sum = sum + self.tree_size(&mut seen, &mut seen_adjacent, e); + sum += self.tree_size(&mut seen, &mut seen_adjacent, e); } sum } @@ -273,7 +273,7 @@ impl Explanation { for child_proof in ¤t.child_proofs { for child in child_proof { - my_size = self.tree_size(seen, seen_adjacent, child); + my_size += self.tree_size(seen, seen_adjacent, child); } } my_size @@ -1492,7 +1492,6 @@ impl Explain { ) { self.shortest_explanation_memo .insert((right, right), (Saturating(0), right)); - let mut last_cost = Saturating(0); for connection in left_connections.iter().rev() { let next = connection.next; let current = connection.current; @@ -1502,7 +1501,6 @@ impl Explain { .unwrap() .0; let dist = self.connection_distance(connection, distance_memo); - last_cost = dist + next_cost; self.replace_distance(current, next, right, next_cost + dist); } } diff --git a/src/test.rs b/src/test.rs index 805a5f73..10815d66 100644 --- a/src/test.rs +++ b/src/test.rs @@ -5,6 +5,8 @@ These are not considered part of the public api. use std::{fmt::Display, fs::File, io::Write, path::PathBuf}; +use saturating::Saturating; + use crate::*; pub fn env_var(s: &str) -> Option @@ -102,14 +104,14 @@ pub fn test_runner( let flattened = explained.make_flat_explanation().clone(); let vanilla_len = flattened.len(); explained.check_proof(rules); - assert!(explained.get_tree_size() > 0); + assert!(explained.get_tree_size() > Saturating(0)); runner = runner.with_explanation_length_optimization(); let mut explained_short = runner.explain_matches(&start, &goal.ast, &subst); explained_short.get_string_with_let(); let short_len = explained_short.get_flat_strings().len(); assert!(short_len <= vanilla_len); - assert!(explained_short.get_tree_size() > 0); + assert!(explained_short.get_tree_size() > Saturating(0)); explained_short.check_proof(rules); } }