summaryrefslogtreecommitdiffstats
path: root/src/format.rs
diff options
context:
space:
mode:
authorpierresy <phsym@msn.com>2016-01-03 14:14:27 +0100
committerpierresy <phsym@msn.com>2016-01-03 14:14:27 +0100
commit93495d81195cd464016612fdd2bed284ddb6a1f0 (patch)
treed65d4ce48389eb69931207252019d24978e49173 /src/format.rs
parentaac360ceac297ed09e1f036381a9ebe9e4ab709d (diff)
Implemented print_align function for #12
Implemented print_align function to replace rust's std fill/align capability.
Diffstat (limited to 'src/format.rs')
-rw-r--r--src/format.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/format.rs b/src/format.rs
index 8b9a32d..91d167f 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -5,7 +5,7 @@ use std::io::{Write, Error};
use super::utils::NEWLINE;
/// Alignment for cell's content
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Copy)]
pub enum Align {
LEFT,
CENTER,
@@ -20,13 +20,13 @@ pub struct LineSeparator {
}
impl LineSeparator {
-
+
/// Create a new line separator instance where `line` is the character used to separate 2 lines
/// and `cross` is the one used when column separaors and line separators cross
pub fn new(line: char, cross: char) -> LineSeparator {
return LineSeparator{line: [line as u8], cross: [cross as u8]};
}
-
+
/// Print a full line separator to `out`. `col_width` is a slice containing the width of each column
pub fn print<T: Write+?Sized>(&self, out: &mut T, col_width: &[usize], with_colsep: bool) -> Result<(), Error> {
if with_colsep {
@@ -51,7 +51,7 @@ pub struct TableFormat {
}
impl TableFormat {
-
+
/// Create a new TableFormat.
///
/// `col_sep` is the character used for separating columns.
@@ -65,7 +65,7 @@ impl TableFormat {
};
return TableFormat{col_sep: csep, line_sep: line_sep, title_sep: title_sep};
}
-
+
/// Print a full line separator to `out`. `col_width` is a slice containing the width of each column
pub fn print_line_separator<T: Write+?Sized>(&self, out: &mut T, col_width: &[usize]) -> Result<(), Error> {
if let Some(ref l) = self.line_sep {
@@ -73,7 +73,7 @@ impl TableFormat {
}
return Ok(());
}
-
+
/// Print a full title separator to `out`. `col_width` is a slice containing the width of each column
pub fn print_title_separator<T: Write+?Sized>(&self, out: &mut T, col_width: &[usize]) -> Result<(), Error> {
if let Some(ref l) = self.title_sep {
@@ -81,7 +81,7 @@ impl TableFormat {
}
return self.print_line_separator(out, col_width);
}
-
+
/// Print a column separator to `out`
pub fn print_column_separator<T: Write+?Sized>(&self, out: &mut T) -> Result<(), Error> {
return match self.col_sep {