diff options
author | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-06-05 18:40:16 +0200 |
---|---|---|
committer | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-06-05 18:40:16 +0200 |
commit | 1b9555870a24db4181d7d9918f58b6b13dbf17a2 (patch) | |
tree | d158e7a16084756b4dee192eca722f6b266da518 /src | |
parent | a99d195b4a4ed40c969c2dff64353d5273f310a5 (diff) |
Updated according to @hcpl comments
Diffstat (limited to 'src')
-rw-r--r-- | src/format.rs | 23 | ||||
-rw-r--r-- | src/row.rs | 2 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/format.rs b/src/format.rs index 96f9257..e1dcd46 100644 --- a/src/format.rs +++ b/src/format.rs @@ -225,7 +225,7 @@ impl TableFormat { -> Result<(), Error> { match *self.get_sep_for_line(pos) { Some(ref l) => { - write!(out, "{:1$}", "", self.get_indent()); + out.write_all(&vec![b' '; self.get_indent()]); l._print(out, col_width, self.get_padding(), @@ -281,6 +281,11 @@ impl FormatBuilder { FormatBuilder { format: Box::new(format) } } + /// Consumes the builder and returns the generated `TableFormat` + pub fn into_table_format(self) -> TableFormat { + *self.format + } + /// Set left and right padding pub fn padding(mut self, left: usize, right: usize) -> Self { self.format.padding(left, right); @@ -317,12 +322,24 @@ impl FormatBuilder { self } - /// Consume this builder and return the generated `TableFormat` - pub fn build(self) -> TableFormat { + /// Return the generated `TableFormat` + pub fn build(&self) -> TableFormat { *self.format } } +impl Into<TableFormat> for FormatBuilder { + fn into(self) -> TableFormat { + self.into_table_format() + } +} + +impl From<TableFormat> for FormatBuilder { + fn from(fmt: TableFormat) -> Self { + Self::from_format(fmt) + } +} + /// Predifined formats. Those constants are lazily evaluated when /// the corresponding struct is dereferenced pub mod consts { @@ -119,7 +119,7 @@ impl Row { where F: Fn(&Cell, &mut T, usize, usize, bool) -> Result<(), Error> { for i in 0..self.get_height() { - write!(out, "{:1$}", "", format.get_indent()); + out.write_all(&vec![b' '; format.get_indent()]); try!(format.print_column_separator(out, ColumnPosition::Left)); let (lp, rp) = format.get_padding(); for j in 0..col_width.len() { |