summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2017-06-05 18:40:16 +0200
committerPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2017-06-05 18:40:16 +0200
commit1b9555870a24db4181d7d9918f58b6b13dbf17a2 (patch)
treed158e7a16084756b4dee192eca722f6b266da518 /src
parenta99d195b4a4ed40c969c2dff64353d5273f310a5 (diff)
Updated according to @hcpl comments
Diffstat (limited to 'src')
-rw-r--r--src/format.rs23
-rw-r--r--src/row.rs2
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 {
diff --git a/src/row.rs b/src/row.rs
index 98b0677..45497c6 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -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() {