From eecfd8836359e66dd1f20c1d387fc3ffa0c39f9a Mon Sep 17 00:00:00 2001 From: Ben S Date: Mon, 30 Jun 2014 09:59:54 +0100 Subject: [PATCH] Simplify alignment code --- src/column.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/column.rs b/src/column.rs index dc65558..1839275 100644 --- a/src/column.rs +++ b/src/column.rs @@ -48,23 +48,10 @@ impl Column { impl Alignment { pub fn pad_string(&self, string: &String, padding: uint) -> String { - let mut str = String::new(); match *self { - Left => { - str.push_str(string.as_slice()); - for _ in range(0, padding) { - str.push_char(' '); - } - } - - Right => { - for _ in range(0, padding) { - str.push_char(' '); - } - str.push_str(string.as_slice()); - }, + Left => string.clone().append(" ".to_string().repeat(padding).as_slice()), + Right => " ".to_string().repeat(padding).append(string.as_slice()), } - return str; } }