From 4f262eccd55e08c73e95a30d873f7fc917b2c989 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Mon, 21 Feb 2022 18:30:17 -0500 Subject: [PATCH] Fix error for subselection sort --- src/sort.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sort.rs b/src/sort.rs index e8ae900..9b998cd 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -43,10 +43,12 @@ fn get_sortable_selections_subselections<'a, 'b, 'tmp, S: AsRef + std::fmt: subselections: &'a [S], subselections_desc: &'tmp [S], ) -> Result>, KakMessage> { - eprintln!( - "All units: {:?}\n{:?}\n{:?}\n{:?}", - selections, selections_desc, subselections, subselections_desc, - ); + if selections.len() != selections_desc.len() || subselections.len() != subselections_desc.len() + { + return Err(KakMessage ("Internal error".to_string(), Some( + format!("Counts for selections={}, selections_desc={}, subselections={}, subselections_desc={}",selections.len(),selections_desc.len(),subselections.len(),subselections_desc.len()) + ))); + } let mut sortable_selections = selections .iter() .zip(selections_desc.iter()) @@ -82,7 +84,7 @@ fn get_sortable_selections_subselections<'a, 'b, 'tmp, S: AsRef + std::fmt: // If one has more subselections than the other, stop comparing for (a_subsel, b_subsel) in a.subselections.iter().zip(b.subselections.iter()) { match a_subsel.cmp(b_subsel) { - // These subselecitons are equal, so we can't do anything + // These subselections are equal, so we can't do anything Ordering::Equal => continue, // We found a difference, so return the comparison o => return o,