|
|
@@ -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()),
|
|
|
}
|
|
|
}
|
|
|
}
|