Fix error for subselection sort

This commit is contained in:
Austen Adler 2022-02-21 18:30:17 -05:00
parent 3b7646c04e
commit 4f262eccd5

View File

@ -43,10 +43,12 @@ fn get_sortable_selections_subselections<'a, 'b, 'tmp, S: AsRef<str> + std::fmt:
subselections: &'a [S], subselections: &'a [S],
subselections_desc: &'tmp [S], subselections_desc: &'tmp [S],
) -> Result<Vec<SortableSelection<'a>>, KakMessage> { ) -> Result<Vec<SortableSelection<'a>>, KakMessage> {
eprintln!( if selections.len() != selections_desc.len() || subselections.len() != subselections_desc.len()
"All units: {:?}\n{:?}\n{:?}\n{:?}", {
selections, selections_desc, subselections, subselections_desc, 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 let mut sortable_selections = selections
.iter() .iter()
.zip(selections_desc.iter()) .zip(selections_desc.iter())
@ -82,7 +84,7 @@ fn get_sortable_selections_subselections<'a, 'b, 'tmp, S: AsRef<str> + std::fmt:
// If one has more subselections than the other, stop comparing // If one has more subselections than the other, stop comparing
for (a_subsel, b_subsel) in a.subselections.iter().zip(b.subselections.iter()) { for (a_subsel, b_subsel) in a.subselections.iter().zip(b.subselections.iter()) {
match a_subsel.cmp(b_subsel) { 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, Ordering::Equal => continue,
// We found a difference, so return the comparison // We found a difference, so return the comparison
o => return o, o => return o,