Clone less in 2020/07

This commit is contained in:
kageru 2020-12-07 12:14:45 +01:00
parent 9a941e9d00
commit c00955ab2c
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

@ -47,9 +47,9 @@ fn read_input() -> String {
std::fs::read_to_string("input").unwrap() std::fs::read_to_string("input").unwrap()
} }
fn part1<'a>(bags: &[Bag], color: &str, seen: &'a mut HashSet<String>) -> &'a mut HashSet<String> { fn part1<'a, 'b>(bags: &'b [Bag], color: &str, seen: &'a mut HashSet<&'b str>) -> &'a mut HashSet<&'b str> {
for bag in bags.iter().filter(|bag| bag.contents.iter().any(|b| b.color == color)) { for bag in bags.iter().filter(|bag| bag.contents.iter().any(|b| b.color == color)) {
seen.insert(bag.color.clone()); seen.insert(&bag.color);
part1(bags, &bag.color, seen); part1(bags, &bag.color, seen);
} }
seen seen