// TODO: The formatting functions below are bloody ugly. Part of this is because
// formatting with proper alignment is a lot harder than it seems at first
// sight. But propably some things can be simplified by using the std::fmt
// formatter and args to build up a format string and pass in the right values.
The formatting functions below are bloody ugly. Part of this is because
formatting with proper alignment is a lot harder than it seems at first
sight. But propably some things can be simplified by using the std::fmt
formatter and args to build up a format string and pass in the right values.
The formatting functions below are bloody ugly . Part of this is because formatting with proper alignment is a lot harder than it seems at first sight . But propably some things can be simplified by using the std :: fmt formatter and args to build up a format string and pass in the right values .
fn format_row<'a, W, ElemIter, WidthIter>(
    writer: &mut W,
    begin: &'a str,
    elems: ElemIter,
    widths: WidthIter,
    sep: &'a str,
    end: &'a str
    ) -> io::Result<()>
where
  W: io::Write,
  ElemIter: IntoIterator<Item = &'a str>,
  WidthIter: IntoIterator<Item = usize>,
{
    write!(writer, "{}", begin)?;
    let mut needs_sep = false;
    for (elem, w) in elems.into_iter().zip(widths) {
        if needs_sep {
            write!(writer, "{}", sep)?;
        }
        write!(writer, "{}", elem)?;
        let len = elem.chars().count();
        assert!(len <= w);
        write!(writer, "{}", " ".repeat(w - len))?;
        needs_sep = true;
    }
    write!(writer, "{}", end)
}
fn format_row < ' a , W , ElemIter , WidthIter > ( writer : & mut W , begin : & ' a str , elems : ElemIter , widths : WidthIter , sep : & ' a str , end : & ' a str ) -> io :: Result < ( ) > where W : io :: Write , ElemIter : IntoIterator < Item = & ' a str > , WidthIter : IntoIterator < Item = usize > , { write ! ( writer " " begin ) ? ; let mut needs_sep = false ; for ( elem , w ) in elems . into_iter ( ) . zip ( widths ) { if needs_sep { write ! ( writer " " sep ) ? ; } write ! ( writer " " elem ) ? ; let len = elem . chars ( ) . count ( ) ; assert ! ( len w ) ; write ! ( writer " " " " repeat ( w len ) ) ? ; needs_sep = true ; } write ! ( writer " " end ) }
TODO: The formatting functions below are bloody ugly.
TODO : The formatting functions below are bloody ugly .
writer
&mut W
begin
&'a str
elems
ElemIter
widths
WidthIter
sep
&'a str
end
&'a str