3 ms·
> dic = {k: v for k, v in dic.items() if k in other_dic and v == "bar"} dic.iter().filter(|k, v| other_dic.contains(k) && v == "bar").collect(); it's one line
by fiedzia 7y ago
> dic = {k: v for k, v in dic.items() if k in other_dic and v == "bar"}
dic.iter().filter(|k, v| other_dic.contains(k) && v == "bar").collect();
it's one line, though I'd format it as 3 for readability (list comprehension is hard to read and functional style composes better.