fn remove_prefix_words(list: Vec<String>) -> Vec<String> {
    let mut list_without_prefix_words = list.to_vec();
    list_without_prefix_words.retain(|potential_prefix_word| {
        for word in &list {
            if word.starts_with(potential_prefix_word) && word != potential_prefix_word {
                // This is a prefix word, so we do NOT want to retain it. return false to the
                // retain
                return false;
            } else {
                // This particular word is not a prefix word of this potential_prefix_word.
                // keep looping
                continue;
            };
        }
        // If we've made it here, we can be sure that potential_prefix_word is NOT a
        // prefix word. So we want to retain it for the list_without_prefix_words.
        // To do this, we return true to the retain.
        true
    });
    list_without_prefix_words
}
/// Remove prefix words from the given Vector of `String`s.
///
/// A brief example: If both "news" and "newspaper" are on the inputted list
/// we may, for cryptographic reasons, want to remove the prefix word,
/// which is "news" in this case.
Remove prefix words from the given Vector of `String`s.
Remove prefix words from the given Vector of ` String ` s .
fn remove_prefix_words(list: Vec<String>) -> Vec<String> {
    let mut list_without_prefix_words = list.to_vec();
    list_without_prefix_words.retain(|potential_prefix_word| {
        for word in &list {
            if word.starts_with(potential_prefix_word) && word != potential_prefix_word {
                // This is a prefix word, so we do NOT want to retain it. return false to the
                // retain
                return false;
            } else {
                // This particular word is not a prefix word of this potential_prefix_word.
                // keep looping
                continue;
            };
        }
        // If we've made it here, we can be sure that potential_prefix_word is NOT a
        // prefix word. So we want to retain it for the list_without_prefix_words.
        // To do this, we return true to the retain.
        true
    });
    list_without_prefix_words
}
fn remove_prefix_words ( list : Vec < String > ) -> Vec < String > { let mut list_without_prefix_words = list . to_vec ( ) ; list_without_prefix_words . retain ( | potential_prefix_word | { for word in & list { if word . starts_with ( potential_prefix_word ) && word != potential_prefix_word { // This is a prefix word, so we do NOT want to retain it. return false to the // retain return false ; } else { // This particular word is not a prefix word of this potential_prefix_word. // keep looping continue ; } ; } // If we've made it here, we can be sure that potential_prefix_word is NOT a // prefix word. So we want to retain it for the list_without_prefix_words. // To do this, we return true to the retain. true } ) ; list_without_prefix_words }
Remove prefix words from the given Vector of `String`s.
Remove prefix words from the given Vector of ` String ` s .
list
Vec<String>
list
Vec<String>