Simplify alignment code

This commit is contained in:
Ben S 2014-06-30 09:59:54 +01:00
parent 178e24552d
commit eecfd88363

View File

@ -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;
}
}