diff options
author | pierresy <pierre-henri.symoneaux@alcatel-lucent.com> | 2016-01-17 23:15:06 +0100 |
---|---|---|
committer | pierresy <pierre-henri.symoneaux@alcatel-lucent.com> | 2016-01-17 23:15:06 +0100 |
commit | 8fbd2af468da9eddf2f2e21238141212f4c88e88 (patch) | |
tree | 29635f8faecb7f6acba80b0a10ba502064c0d250 /src/cell.rs | |
parent | 7933962dc38d6dc7e0cad206d24555ed15ee7dd1 (diff) |
Implemented padding customization
Diffstat (limited to 'src/cell.rs')
-rw-r--r-- | src/cell.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/cell.rs b/src/cell.rs index 7487234..4c028b1 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -179,9 +179,7 @@ impl Cell { Some(s) => s.as_ref(),
None => ""
};
- try!(write!(out, " "));
- try!(print_align(out, self.align, c, ' ', col_width));
- return write!(out, " ");
+ return print_align(out, self.align, c, ' ', col_width)
}
/// Apply style then call `print` to print the cell into a terminal
@@ -284,7 +282,7 @@ mod tests { let mut out = StringWriter::new();
let _ = ascii_cell.print(&mut out, 0, 10);
- assert_eq!(out.as_string(), " hello ");
+ assert_eq!(out.as_string(), "hello ");
}
#[test]
@@ -294,7 +292,7 @@ mod tests { let mut out = StringWriter::new();
let _ = unicode_cell.print(&mut out, 0, 10);
- assert_eq!(out.as_string(), " привет ");
+ assert_eq!(out.as_string(), "привет ");
}
#[test]
@@ -303,7 +301,7 @@ mod tests { assert_eq!(unicode_cell.get_width(), 14);
let mut out = StringWriter::new();
let _ = unicode_cell.print(&mut out, 0, 20);
- assert_eq!(out.as_string(), " 由系统自动更新 ");
+ assert_eq!(out.as_string(), "由系统自动更新 ");
}
#[test]
@@ -311,7 +309,7 @@ mod tests { let cell = Cell::new_align("test", Alignment::LEFT);
let mut out = StringWriter::new();
let _ = cell.print(&mut out, 0, 10);
- assert_eq!(out.as_string(), " test ");
+ assert_eq!(out.as_string(), "test ");
}
#[test]
@@ -319,7 +317,7 @@ mod tests { let cell = Cell::new_align("test", Alignment::CENTER);
let mut out = StringWriter::new();
let _ = cell.print(&mut out, 0, 10);
- assert_eq!(out.as_string(), " test ");
+ assert_eq!(out.as_string(), " test ");
}
#[test]
@@ -327,7 +325,7 @@ mod tests { let cell = Cell::new_align("test", Alignment::RIGHT);
let mut out = StringWriter::new();
let _ = cell.print(&mut out, 0, 10);
- assert_eq!(out.as_string(), " test ");
+ assert_eq!(out.as_string(), " test");
}
#[test]
|