fn make_columns(mut words: Vec<String>, terminal_width: usize) -> Vec<Vec<String>> {

        let word_lengths: Vec<usize> =
            words.iter().map(|x: &String| -> usize {(&x).len() + 2}).collect();

        let columns_amt = bin_search( word_lengths.iter().fold(0   , |x, y| {min(x, *y)})
                                    , word_lengths.iter().fold(1000, |x, y| {max(x, *y)})
                                    , &word_lengths
                                    , terminal_width);

        let longest_words: Vec<usize> =
            split_into_columns( &word_lengths
                              , columns_amt
                              , (words.len() / columns_amt) + 1
                              ).iter().map(longest_word).collect();

        let mut words_with_space: Vec<String> = Vec::new();
        let lines_amt = (words.len() / columns_amt) + 1;
        let mut longest_words_rep = Vec::new();
        for longest_word in longest_words {
            for _ in 0..lines_amt {
                longest_words_rep.push(longest_word.clone());
            }
        }

        for i in 0..words.len() {

            let whitespace = " ".repeat(longest_words_rep[i] - words[i].len());
            words[i].push_str(whitespace.as_str());
            words_with_space.push(words[i].clone());
        }

        split_into_columns::<String>(&words_with_space, columns_amt, (words.len() / columns_amt) + 1)
    }
/// Turns the list of words into this: line<columns<word>>
Turns the list of words into this: line>
Turns the list of words into this : line >
fn make_columns(mut words: Vec<String>, terminal_width: usize) -> Vec<Vec<String>> {
        let word_lengths: Vec<usize> =
            words.iter().map(|x: &String| -> usize {(&x).len() + 2}).collect();
        let columns_amt = bin_search( word_lengths.iter().fold(0   , |x, y| {min(x, *y)})
                                    , word_lengths.iter().fold(1000, |x, y| {max(x, *y)})
                                    , &word_lengths
                                    , terminal_width);
        let longest_words: Vec<usize> =
            split_into_columns( &word_lengths
                              , columns_amt
                              , (words.len() / columns_amt) + 1
                              ).iter().map(longest_word).collect();
        let mut words_with_space: Vec<String> = Vec::new();
        let lines_amt = (words.len() / columns_amt) + 1;
        let mut longest_words_rep = Vec::new();
        for longest_word in longest_words {
            for _ in 0..lines_amt {
                longest_words_rep.push(longest_word.clone());
            }
        }
        for i in 0..words.len() {
            let whitespace = " ".repeat(longest_words_rep[i] - words[i].len());
            words[i].push_str(whitespace.as_str());
            words_with_space.push(words[i].clone());
        }
        split_into_columns::<String>(&words_with_space, columns_amt, (words.len() / columns_amt) + 1)
    }
fn make_columns ( mut words : Vec < String > , terminal_width : usize ) -> Vec < Vec < String > > { let word_lengths : Vec < usize > = words . iter ( ) . map ( | x : & String | -> usize { ( & x ) . len ( ) + 2 } ) . collect ( ) ; let columns_amt = bin_search ( word_lengths . iter ( ) . fold ( 0 , | x , y | { min ( x , * y ) } ) , word_lengths . iter ( ) . fold ( 1000 , | x , y | { max ( x , * y ) } ) , & word_lengths , terminal_width ) ; let longest_words : Vec < usize > = split_into_columns ( & word_lengths , columns_amt , ( words . len ( ) / columns_amt ) + 1 ) . iter ( ) . map ( longest_word ) . collect ( ) ; let mut words_with_space : Vec < String > = Vec :: new ( ) ; let lines_amt = ( words . len ( ) / columns_amt ) + 1 ; let mut longest_words_rep = Vec :: new ( ) ; for longest_word in longest_words { for _ in 0 .. lines_amt { longest_words_rep . push ( longest_word . clone ( ) ) ; } } for i in 0 .. words . len ( ) { let whitespace = " " . repeat ( longest_words_rep [ i ] - words [ i ] . len ( ) ) ; words [ i ] . push_str ( whitespace . as_str ( ) ) ; words_with_space . push ( words [ i ] . clone ( ) ) ; } split_into_columns :: < String > ( & words_with_space , columns_amt , ( words . len ( ) / columns_amt ) + 1 ) }
Turns the list of words into this: line<columns<word>>
Turns the list of words into this : line<columns<word >>
words
Vec<String>
terminal_width
usize