This commit is contained in:
Simon Gardling
2022-05-04 23:43:50 -04:00
parent 5e5dd0f7a6
commit 243135b3dc
8 changed files with 47 additions and 30 deletions

View File

@@ -30,9 +30,12 @@ pub fn compile_hashmap(data: Vec<String>) -> Vec<(String, String)> {
}
seen_3.insert(key.clone());
if keys.iter().filter(|a| a == &&key).count() == 1 {
let count_keys = keys.iter().filter(|a| a == &&key).count();
if count_keys == 1 {
output.push((key.clone(), format!(r#"Hint::Single("{}")"#, value)));
} else {
} else if count_keys > 1 {
let mut multi_data = tuple_list_1
.iter()
.filter(|(a, _)| a == key)
@@ -40,6 +43,8 @@ pub fn compile_hashmap(data: Vec<String>) -> Vec<(String, String)> {
.collect::<Vec<&String>>();
multi_data.sort_unstable_by(|a, b| compare_len_reverse_alpha(a, b));
output.push((key.clone(), format!("Hint::Many(&{:?})", multi_data)));
} else {
panic!("Number of values for {key} is 0!");
}
}
output