From 93495d81195cd464016612fdd2bed284ddb6a1f0 Mon Sep 17 00:00:00 2001 From: pierresy Date: Sun, 3 Jan 2016 14:14:27 +0100 Subject: Implemented print_align function for #12 Implemented print_align function to replace rust's std fill/align capability. --- src/format.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/format.rs') 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(&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(&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(&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(&self, out: &mut T) -> Result<(), Error> { return match self.col_sep { -- cgit v1.2.3