pub fn tidy_list(req: TidyRequest) -> Vec<String> {
    // guess this function is what I should clean-up next...
    // Remove blank lines first
    let mut tidied_list = remove_blank_lines(&req.list);
    tidied_list = if req.should_delete_through_first_tab {
        tidied_list
            .iter()
            // Should figure out how to remove these to_string calls
            .map(|w| delete_through_first_char(w, '\t').to_string())
            .collect()
    } else {
        tidied_list
    };
    tidied_list = if req.should_delete_through_first_space {
        tidied_list
            .iter()
            .map(|w| delete_through_first_char(w, ' ').to_string())
            .collect()
    } else {
        tidied_list
    };
    tidied_list = if req.should_delete_integers {
        tidied_list
            .iter()
            .map(|w| delete_integers(w.to_string()))
            .collect()
    } else {
        tidied_list
    };
    tidied_list = if req.should_delete_nonalphanumeric {
        tidied_list
            .iter()
            .map(|w| delete_nonalphanumeric(w.to_string()))
            .collect()
    } else {
        tidied_list
    };
    tidied_list = trim_whitespace(&tidied_list);
    // We're going to check for blank lines again in
    // case we made any lines blank with delete/trim calls
    tidied_list = remove_blank_lines(&tidied_list);
    // Now truncate list, if requested
    // Maybe should move this up in the order though...
    tidied_list = match req.take_first {
        Some(amount_to_take) => {
            tidied_list.truncate(amount_to_take);
            tidied_list
        }
        None => tidied_list,
    };
    tidied_list = match req.take_rand {
        Some(amount_to_take) => {
            let mut rng = thread_rng();
            tidied_list.shuffle(&mut rng);
            tidied_list.truncate(amount_to_take);
            tidied_list
        }
        None => tidied_list,
    };
    tidied_list = if req.to_lowercase {
        tidied_list.iter().map(|w| w.to_ascii_lowercase()).collect()
    } else {
        tidied_list
    };
    // Move on to word removals
    tidied_list = if req.should_remove_nonalphanumeric {
        remove_nonalphanumeric(&tidied_list)
    } else {
        tidied_list
    };
    tidied_list = if req.should_remove_nonalphabetic {
        remove_nonalphabetic(&tidied_list)
    } else {
        tidied_list
    };
    tidied_list = if req.should_remove_integers {
        remove_integers(&tidied_list)
    } else {
        tidied_list
    };
    tidied_list = match req.reject_list {
        Some(reject_list) => remove_reject_words(tidied_list, reject_list),
        None => tidied_list,
    };
    tidied_list = match req.approved_list {
        Some(approved_list) => remove_words_not_on_approved_list(tidied_list, approved_list),
        None => tidied_list,
    };
    tidied_list = match req.minimum_length {
        Some(minimum_length) => remove_words_below_minimum_length(tidied_list, minimum_length),
        None => tidied_list,
    };
    tidied_list = match req.maximum_length {
        Some(maximum_length) => remove_words_above_maximum_length(tidied_list, maximum_length),
        None => tidied_list,
    };
    tidied_list = match req.homophones_list {
        Some(homophones_list) => remove_homophones(tidied_list, homophones_list),
        None => tidied_list,
    };
    // I think this is a good order for these next 3 operations,
    // but I'm not super confident
    tidied_list = match req.minimum_edit_distance {
        Some(minimum_edit_distance) => {
            enfore_minimum_edit_distance(tidied_list, minimum_edit_distance)
        }
        None => tidied_list,
    };
    tidied_list = if req.should_remove_prefix_words {
        remove_prefix_words(sort_and_dedup(&mut tidied_list))
    } else {
        tidied_list
    };
    tidied_list = match req.maximum_shared_prefix_length {
        Some(maximum_shared_prefix_length) => {
            guarantee_maximum_prefix_length(&tidied_list, maximum_shared_prefix_length)
        }
        None => tidied_list,
    };

    // Sort and dedup here
    tidied_list = sort_and_dedup(&mut tidied_list);

    // User can cut words from nearly finished list.
    // Does so randomly.
    tidied_list = match req.cut_to {
        Some(amount_to_cut) => {
            let mut rng = thread_rng();
            tidied_list.shuffle(&mut rng);
            tidied_list.truncate(amount_to_cut);
            tidied_list
        }
        None => tidied_list,
    };
    // Finally, sort and dedup list (for final time)
    tidied_list = sort_and_dedup(&mut tidied_list);
    tidied_list
}
/// This is the large, key function of the program. It takes
/// a `TidyRequest` object -- which includes the word list --
/// and performs whatever functions the user has requesteed to
/// perform on the list.
This is the large, key function of the program. It takes
a `TidyRequest` object -- which includes the word list
and performs whatever functions the user has requesteed to
perform on the list.
This is the large key function of the program . It takes a ` TidyRequest ` object -- which includes the word list and performs whatever functions the user has requesteed to perform on the list .
pub fn tidy_list(req: TidyRequest) -> Vec<String> {
    // guess this function is what I should clean-up next...
    // Remove blank lines first
    let mut tidied_list = remove_blank_lines(&req.list);
    tidied_list = if req.should_delete_through_first_tab {
        tidied_list
            .iter()
            // Should figure out how to remove these to_string calls
            .map(|w| delete_through_first_char(w, '\t').to_string())
            .collect()
    } else {
        tidied_list
    };
    tidied_list = if req.should_delete_through_first_space {
        tidied_list
            .iter()
            .map(|w| delete_through_first_char(w, ' ').to_string())
            .collect()
    } else {
        tidied_list
    };
    tidied_list = if req.should_delete_integers {
        tidied_list
            .iter()
            .map(|w| delete_integers(w.to_string()))
            .collect()
    } else {
        tidied_list
    };
    tidied_list = if req.should_delete_nonalphanumeric {
        tidied_list
            .iter()
            .map(|w| delete_nonalphanumeric(w.to_string()))
            .collect()
    } else {
        tidied_list
    };
    tidied_list = trim_whitespace(&tidied_list);
    // We're going to check for blank lines again in
    // case we made any lines blank with delete/trim calls
    tidied_list = remove_blank_lines(&tidied_list);
    // Now truncate list, if requested
    // Maybe should move this up in the order though...
    tidied_list = match req.take_first {
        Some(amount_to_take) => {
            tidied_list.truncate(amount_to_take);
            tidied_list
        }
        None => tidied_list,
    };
    tidied_list = match req.take_rand {
        Some(amount_to_take) => {
            let mut rng = thread_rng();
            tidied_list.shuffle(&mut rng);
            tidied_list.truncate(amount_to_take);
            tidied_list
        }
        None => tidied_list,
    };
    tidied_list = if req.to_lowercase {
        tidied_list.iter().map(|w| w.to_ascii_lowercase()).collect()
    } else {
        tidied_list
    };
    // Move on to word removals
    tidied_list = if req.should_remove_nonalphanumeric {
        remove_nonalphanumeric(&tidied_list)
    } else {
        tidied_list
    };
    tidied_list = if req.should_remove_nonalphabetic {
        remove_nonalphabetic(&tidied_list)
    } else {
        tidied_list
    };
    tidied_list = if req.should_remove_integers {
        remove_integers(&tidied_list)
    } else {
        tidied_list
    };
    tidied_list = match req.reject_list {
        Some(reject_list) => remove_reject_words(tidied_list, reject_list),
        None => tidied_list,
    };
    tidied_list = match req.approved_list {
        Some(approved_list) => remove_words_not_on_approved_list(tidied_list, approved_list),
        None => tidied_list,
    };
    tidied_list = match req.minimum_length {
        Some(minimum_length) => remove_words_below_minimum_length(tidied_list, minimum_length),
        None => tidied_list,
    };
    tidied_list = match req.maximum_length {
        Some(maximum_length) => remove_words_above_maximum_length(tidied_list, maximum_length),
        None => tidied_list,
    };
    tidied_list = match req.homophones_list {
        Some(homophones_list) => remove_homophones(tidied_list, homophones_list),
        None => tidied_list,
    };
    // I think this is a good order for these next 3 operations,
    // but I'm not super confident
    tidied_list = match req.minimum_edit_distance {
        Some(minimum_edit_distance) => {
            enfore_minimum_edit_distance(tidied_list, minimum_edit_distance)
        }
        None => tidied_list,
    };
    tidied_list = if req.should_remove_prefix_words {
        remove_prefix_words(sort_and_dedup(&mut tidied_list))
    } else {
        tidied_list
    };
    tidied_list = match req.maximum_shared_prefix_length {
        Some(maximum_shared_prefix_length) => {
            guarantee_maximum_prefix_length(&tidied_list, maximum_shared_prefix_length)
        }
        None => tidied_list,
    };
    // Sort and dedup here
    tidied_list = sort_and_dedup(&mut tidied_list);
    // User can cut words from nearly finished list.
    // Does so randomly.
    tidied_list = match req.cut_to {
        Some(amount_to_cut) => {
            let mut rng = thread_rng();
            tidied_list.shuffle(&mut rng);
            tidied_list.truncate(amount_to_cut);
            tidied_list
        }
        None => tidied_list,
    };
    // Finally, sort and dedup list (for final time)
    tidied_list = sort_and_dedup(&mut tidied_list);
    tidied_list
}
pub fn tidy_list ( req : TidyRequest ) -> Vec < String > { // guess this function is what I should clean-up next... // Remove blank lines first let mut tidied_list = remove_blank_lines ( & req . list ) ; tidied_list = if req . should_delete_through_first_tab { tidied_list . iter ( ) // Should figure out how to remove these to_string calls . map ( | w | delete_through_first_char ( w , '\t' ) . to_string ( ) ) . collect ( ) } else { tidied_list } ; tidied_list = if req . should_delete_through_first_space { tidied_list . iter ( ) . map ( | w | delete_through_first_char ( w , ' ' ) . to_string ( ) ) . collect ( ) } else { tidied_list } ; tidied_list = if req . should_delete_integers { tidied_list . iter ( ) . map ( | w | delete_integers ( w . to_string ( ) ) ) . collect ( ) } else { tidied_list } ; tidied_list = if req . should_delete_nonalphanumeric { tidied_list . iter ( ) . map ( | w | delete_nonalphanumeric ( w . to_string ( ) ) ) . collect ( ) } else { tidied_list } ; tidied_list = trim_whitespace ( & tidied_list ) ; // We're going to check for blank lines again in // case we made any lines blank with delete/trim calls tidied_list = remove_blank_lines ( & tidied_list ) ; // Now truncate list, if requested // Maybe should move this up in the order though... tidied_list = match req . take_first { Some ( amount_to_take ) => { tidied_list . truncate ( amount_to_take ) ; tidied_list } None => tidied_list , } ; tidied_list = match req . take_rand { Some ( amount_to_take ) => { let mut rng = thread_rng ( ) ; tidied_list . shuffle ( & mut rng ) ; tidied_list . truncate ( amount_to_take ) ; tidied_list } None => tidied_list , } ; tidied_list = if req . to_lowercase { tidied_list . iter ( ) . map ( | w | w . to_ascii_lowercase ( ) ) . collect ( ) } else { tidied_list } ; // Move on to word removals tidied_list = if req . should_remove_nonalphanumeric { remove_nonalphanumeric ( & tidied_list ) } else { tidied_list } ; tidied_list = if req . should_remove_nonalphabetic { remove_nonalphabetic ( & tidied_list ) } else { tidied_list } ; tidied_list = if req . should_remove_integers { remove_integers ( & tidied_list ) } else { tidied_list } ; tidied_list = match req . reject_list { Some ( reject_list ) => remove_reject_words ( tidied_list , reject_list ) , None => tidied_list , } ; tidied_list = match req . approved_list { Some ( approved_list ) => remove_words_not_on_approved_list ( tidied_list , approved_list ) , None => tidied_list , } ; tidied_list = match req . minimum_length { Some ( minimum_length ) => remove_words_below_minimum_length ( tidied_list , minimum_length ) , None => tidied_list , } ; tidied_list = match req . maximum_length { Some ( maximum_length ) => remove_words_above_maximum_length ( tidied_list , maximum_length ) , None => tidied_list , } ; tidied_list = match req . homophones_list { Some ( homophones_list ) => remove_homophones ( tidied_list , homophones_list ) , None => tidied_list , } ; // I think this is a good order for these next 3 operations, // but I'm not super confident tidied_list = match req . minimum_edit_distance { Some ( minimum_edit_distance ) => { enfore_minimum_edit_distance ( tidied_list , minimum_edit_distance ) } None => tidied_list , } ; tidied_list = if req . should_remove_prefix_words { remove_prefix_words ( sort_and_dedup ( & mut tidied_list ) ) } else { tidied_list } ; tidied_list = match req . maximum_shared_prefix_length { Some ( maximum_shared_prefix_length ) => { guarantee_maximum_prefix_length ( & tidied_list , maximum_shared_prefix_length ) } None => tidied_list , } ; // Sort and dedup here tidied_list = sort_and_dedup ( & mut tidied_list ) ; // User can cut words from nearly finished list. // Does so randomly. tidied_list = match req . cut_to { Some ( amount_to_cut ) => { let mut rng = thread_rng ( ) ; tidied_list . shuffle ( & mut rng ) ; tidied_list . truncate ( amount_to_cut ) ; tidied_list } None => tidied_list , } ; // Finally, sort and dedup list (for final time) tidied_list = sort_and_dedup ( & mut tidied_list ) ; tidied_list }
This is the large, key function of the program.
This is the large key function of the program .
req
TidyRequest
req
TidyRequest