diff --git a/src/cmd_check_missing.rs b/src/cmd_check_missing.rs index 543ff6b..800db03 100644 --- a/src/cmd_check_missing.rs +++ b/src/cmd_check_missing.rs @@ -9,48 +9,46 @@ pub async fn check_missing(args: CheckMissingArgs) { let config: StickerConfig = serde_yaml::from_reader(config_file).expect("could not parse stickers.yml"); - let stickers_for_sticker_sets: Vec<(String, Vec)> = args + let stickers_for_sticker_sets: Vec<(&String, &Vec)> = args .sticker_sets .iter() .map(|pack_id| { - return ( - pack_id.clone(), - config.sticker_sets.get(pack_id).unwrap().clone(), - ); + return (pack_id, config.sticker_sets.get(pack_id).unwrap()); }) .collect(); - let missing_stickers: Vec<(String, Vec)> = stickers_for_sticker_sets + let missing_stickers: Vec<(&String, Vec<&String>)> = stickers_for_sticker_sets .iter() .map(|(sticker_set_name, sticker_set_stickers)| { return ( - sticker_set_name.clone(), + *sticker_set_name, config .stickers .iter() .filter(|all_stickers_sticker| { !sticker_set_stickers.contains(all_stickers_sticker.0) }) - .map(|b| b.0.clone()) - .collect::>(), + .map(|b| b.0) + .collect::>(), ); }) .collect(); - let total_missing: Vec = HashMap::::from_iter( + let total_missing: Vec<&String> = HashMap::<&String, bool>::from_iter( missing_stickers .iter() .map(|(_pack_name, stickers)| stickers.clone()) - .collect::>>() + .collect::>>() .concat() .iter() - .map(|sticker_name| (sticker_name.clone(), true)), + .map(|sticker_name| (*sticker_name, true)), ) .into_keys() .collect(); let missing_from_all: Vec<&String> = total_missing - .iter() + .clone() + .into_iter() .filter(|missing_sticker| { return missing_stickers .iter()