fn remove_homophones(list: Vec<String>, homophones: Vec<(String, String)>) -> Vec<String> {
    let mut words_to_remove = vec![];
    for pair_of_homophones in homophones {
        if list.contains(&pair_of_homophones.0)
            && list.contains(&pair_of_homophones.1)
            && !(words_to_remove.contains(&pair_of_homophones.0)
                || words_to_remove.contains(&pair_of_homophones.1))
        {
            words_to_remove.push(pair_of_homophones.1);
        }
    }
    let mut new_list = list.to_vec();
    new_list.retain(|w| !words_to_remove.contains(w));
    new_list
}
/// Takes the inputted word list and a Vector of tuples of Strings,
/// each representing a pair of homophones, e.g. `("there", "their")`.
/// The function outputs a new list in which, if both homophones
/// are detected, the second homophone is removed.
Takes the inputted word list and a Vector of tuples of Strings,
each representing a pair of homophones, e.g.
Takes the inputted word list and a Vector of tuples of Strings each representing a pair of homophones e . g .
fn remove_homophones(list: Vec<String>, homophones: Vec<(String, String)>) -> Vec<String> {
    let mut words_to_remove = vec![];
    for pair_of_homophones in homophones {
        if list.contains(&pair_of_homophones.0)
            && list.contains(&pair_of_homophones.1)
            && !(words_to_remove.contains(&pair_of_homophones.0)
                || words_to_remove.contains(&pair_of_homophones.1))
        {
            words_to_remove.push(pair_of_homophones.1);
        }
    }
    let mut new_list = list.to_vec();
    new_list.retain(|w| !words_to_remove.contains(w));
    new_list
}
fn remove_homophones ( list : Vec < String > , homophones : Vec < ( String , String ) > ) -> Vec < String > { let mut words_to_remove = vec ! [ ] ; for pair_of_homophones in homophones { if list . contains ( & pair_of_homophones . 0 ) && list . contains ( & pair_of_homophones . 1 ) && ! ( words_to_remove . contains ( & pair_of_homophones . 0 ) || words_to_remove . contains ( & pair_of_homophones . 1 ) ) { words_to_remove . push ( pair_of_homophones . 1 ) ; } } let mut new_list = list . to_vec ( ) ; new_list . retain ( | w | ! words_to_remove . contains ( w ) ) ; new_list }
Takes the inputted word list and a Vector of tuples of Strings,
each representing a pair of homophones, e.g.
Takes the inputted word list and a Vector of tuples of Strings each representing a pair of homophones e . g .
list
Vec<String>
homophones
Vec<(String, String)>
list
Vec<String>
homophones
Vec<(String, String)>