diff options
author | Ben S <ogham@bsago.me> | 2014-12-24 04:31:59 +0000 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2014-12-24 04:31:59 +0000 |
commit | e3a8342173cf1148eb0843c113cd40acece21e26 (patch) | |
tree | 11cd23af819146dcb2fadb841b3d02b08e882d16 /src/column.rs | |
parent | fbdc9c42689b044f27b09685ba80dc3dc2470298 (diff) |
Upgrade code and libraries to latest Rust
std::str changes, and the way macros are expanded.
Diffstat (limited to 'src/column.rs')
-rw-r--r-- | src/column.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/column.rs b/src/column.rs index 97e60c9..5a4bdb0 100644 --- a/src/column.rs +++ b/src/column.rs @@ -1,3 +1,5 @@ +use std::iter::repeat; + pub enum Column { Permissions, FileName, @@ -53,6 +55,10 @@ impl Column { } } +fn spaces(length: uint) -> String { + repeat(" ").take(length).collect() +} + // An Alignment is used to pad a string to a certain length, letting // it pick which end it puts the text on. It takes the amount of // padding to apply, rather than the width the text should end up, @@ -61,8 +67,8 @@ impl Column { impl Alignment { pub fn pad_string(&self, string: &String, padding: uint) -> String { match *self { - Alignment::Left => format!("{}{}", string, " ".repeat(padding).as_slice()), - Alignment::Right => format!("{}{}", " ".repeat(padding), string.as_slice()), + Alignment::Left => format!("{}{}", string, spaces(padding).as_slice()), + Alignment::Right => format!("{}{}", spaces(padding), string.as_slice()), } } } |