pub fn load_words_list(path : &str) -> Vec<String> {

    // Will hold all the words in the dictionary file.
    let mut dictionary_lines : Vec<String> = Vec::new();

    match File::open(path) {
        Ok(file) => {
            // Read all the words and push them to the dictionary vector.
            let mut reader = BufReader::new(file);
            let mut dictionary_data = String::new();
            let _ = reader.read_to_string(&mut dictionary_data);

            for line in dictionary_data.lines() {
                let word = line.to_lowercase();
                dictionary_lines.push(word);
            }

            // Sort the dictionary in order of word length, largest words to smallest words.
            dictionary_lines.sort_by(|a, b| {
                let x = a.len();
                let y = b.len();

                y.cmp(&x)
            });
        },
        Err(err) => {
            println!("Failed to open dictionary file '{}' because: {:?}", path, err);
        }
    }

    dictionary_lines
}
/// Loads all lines in the given file and sorts them
///
/// Assumes the file is newline separated list of words.
Loads all lines in the given file and sorts them
Assumes the file is newline separated list of words.
Loads all lines in the given file and sorts them Assumes the file is newline separated list of words .
pub fn load_words_list(path : &str) -> Vec<String> {
    // Will hold all the words in the dictionary file.
    let mut dictionary_lines : Vec<String> = Vec::new();
    match File::open(path) {
        Ok(file) => {
            // Read all the words and push them to the dictionary vector.
            let mut reader = BufReader::new(file);
            let mut dictionary_data = String::new();
            let _ = reader.read_to_string(&mut dictionary_data);
            for line in dictionary_data.lines() {
                let word = line.to_lowercase();
                dictionary_lines.push(word);
            }
            // Sort the dictionary in order of word length, largest words to smallest words.
            dictionary_lines.sort_by(|a, b| {
                let x = a.len();
                let y = b.len();
                y.cmp(&x)
            });
        },
        Err(err) => {
            println!("Failed to open dictionary file '{}' because: {:?}", path, err);
        }
    }
    dictionary_lines
}
pub fn load_words_list ( path : & str ) -> Vec < String > { // Will hold all the words in the dictionary file. let mut dictionary_lines : Vec < String > = Vec :: new ( ) ; match File :: open ( path ) { Ok ( file ) => { // Read all the words and push them to the dictionary vector. let mut reader = BufReader :: new ( file ) ; let mut dictionary_data = String :: new ( ) ; let _ = reader . read_to_string ( & mut dictionary_data ) ; for line in dictionary_data . lines ( ) { let word = line . to_lowercase ( ) ; dictionary_lines . push ( word ) ; } // Sort the dictionary in order of word length, largest words to smallest words. dictionary_lines . sort_by ( | a , b | { let x = a . len ( ) ; let y = b . len ( ) ; y . cmp ( & x ) } ) ; } , Err ( err ) => { println ! ( " " path err ) ; } } dictionary_lines }
Loads all lines in the given file and sorts them
Assumes the file is newline separated list of words.
Loads all lines in the given file and sorts them Assumes the file is newline separated list of words .
path
&str
path
&str