@@ -2,7 +2,6 @@ extern crate clap;
22extern crate pad;
33
44mod config;
5-
65use pad:: PadStr ;
76use std:: io:: { self , Result , BufRead , BufReader } ;
87use std:: fs:: { self , File } ;
@@ -66,26 +65,23 @@ fn format_pretty(data: &Vec<Vec<String>>) -> String {
6665 . map ( |( s, len) | max ( s. len ( ) , len) )
6766 . collect ( )
6867 ) ;
69- let format_row = |row : & Vec < String > | row. iter ( )
70- . zip ( & lengths)
71- . map ( |( s, len) | s. pad_to_width ( * len) )
72- . collect :: < Vec < _ > > ( )
73- . join ( " | " ) ;
7468
75- let header = format_row ( & data[ 0 ] ) ;
69+ let rows = data. iter ( )
70+ . map ( |row| row. iter ( )
71+ . zip ( & lengths)
72+ . map ( |( s, len) | s. pad_to_width ( * len) )
73+ . collect :: < Vec < _ > > ( )
74+ . join ( " | " )
75+ )
76+ . collect :: < Vec < _ > > ( ) ;
7677 let separator = lengths. iter ( )
7778 . map ( |len| "-" . repeat ( * len) )
7879 . collect :: < Vec < _ > > ( )
7980 . join ( "-|-" ) ;
80- let rows = data[ 1 ..] . iter ( )
81- . map ( format_row)
82- . collect :: < Vec < _ > > ( )
83- . join ( " |\n | " ) ;
84-
8581 [
86- format ! ( "| {} |" , header ) ,
82+ format ! ( "| {} |" , rows [ 0 ] ) ,
8783 format ! ( "|-{}-|" , separator) ,
88- format ! ( "| {} |" , rows) ,
84+ format ! ( "| {} |" , rows[ 1 .. ] . join ( " | \n | " ) ) ,
8985 ] . join ( "\n " )
9086}
9187
0 commit comments