empty cache handling

This commit is contained in:
Luke Hubmayer-Werner 2022-02-04 13:15:10 +10:30
parent 95eff8cfb8
commit 3ddc3204bb
1 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,11 @@ fn simulate(guess: &str, solution: &str, wordcache: &HashMap<String, Vec<String>
}
}
let re = Regex::new(&re_str).unwrap();
wordcache[&hs2str(&required_chars)].iter().filter(|w| re.is_match(w)).cloned().collect()
let cachekey = hs2str(&required_chars);
match wordcache.contains_key(&cachekey) {
true => wordcache[&cachekey].iter().filter(|w| re.is_match(w)).cloned().collect(),
false => Vec::<String>::new(),
}
}
fn find_worstcase(word: &str, wordcache: &HashMap<String, Vec<String>>) -> String {