let goal_string = count_val.abs().to_string();
let goal_parts: Vec<&[u8]> = goal_string.as_bytes().rchunks(3).rev().collect();
let (&last, front) = goal_parts.split_last().unwrap();
+
+ // TODO try refactoring so 'partials' owns the character data; might be
+ // cleaner
+ let last_part_missing_second_last_char = [
+ last.get(..last.len() - 2).unwrap(),
+ slice::from_ref(&last[last.len() - 1])
+ ].concat();
+
let partials: Vec<Vec<&[u8]>> = vec![
// missing last digit
front.iter().cloned().chain([last.get(..last.len() - 1).unwrap()]).collect(),
front.iter().cloned().chain([last.get(..last.len() - 2).unwrap()]).collect(),
// missing second-last digit
- front.iter().cloned().chain([
- last.get(..last.len() - 2).unwrap(),
- slice::from_ref(&last[last.len() - 1]),
- ]).collect(),
+ front.iter().cloned().chain([&last_part_missing_second_last_char[..]]).collect(),
];
// missing any of last two digits or double paste