Upgrade code and libraries to latest Rust

std::str changes, and the way macros are expanded.
This commit is contained in:
Ben S 2014-12-24 04:31:59 +00:00
parent fbdc9c4268
commit e3a8342173
3 changed files with 16 additions and 10 deletions

14
Cargo.lock generated
View File

@ -3,20 +3,20 @@ name = "exa"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ansi_term 0.4.0 (git+https://github.com/ogham/rust-ansi-term.git)", "ansi_term 0.4.0 (git+https://github.com/ogham/rust-ansi-term.git)",
"natord 1.0.0 (git+https://github.com/lifthrasiir/rust-natord.git)", "natord 1.0.1 (git+https://github.com/lifthrasiir/rust-natord.git)",
"number_prefix 0.2.0 (git+https://github.com/ogham/rust-number-prefix.git)", "number_prefix 0.2.0 (git+https://github.com/ogham/rust-number-prefix.git)",
"users 0.1.0 (git+https://github.com/ogham/rust-users.git)", "users 0.1.1 (git+https://github.com/ogham/rust-users.git)",
] ]
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/ogham/rust-ansi-term.git#19b6f71c716ec56fb960c84f3012fb374e8ac1e3" source = "git+https://github.com/ogham/rust-ansi-term.git#7e051531231838dc9431ec099ddf9fe9cc04c558"
[[package]] [[package]]
name = "natord" name = "natord"
version = "1.0.0" version = "1.0.1"
source = "git+https://github.com/lifthrasiir/rust-natord.git#83ebf6e7999fe2646bca45d5f6800728a0bbd5c5" source = "git+https://github.com/lifthrasiir/rust-natord.git#fecab8556a4a6675577166bc2c0e269ede1ccc80"
[[package]] [[package]]
name = "number_prefix" name = "number_prefix"
@ -25,6 +25,6 @@ source = "git+https://github.com/ogham/rust-number-prefix.git#3f690804a3f1704ee9
[[package]] [[package]]
name = "users" name = "users"
version = "0.1.0" version = "0.1.1"
source = "git+https://github.com/ogham/rust-users.git#221a1463d3e25acac41615186a1c7fdcf0ad36d7" source = "git+https://github.com/ogham/rust-users.git#c2911ab96a2b2459333029dde3728bfb5847ef04"

View File

@ -1,3 +1,5 @@
use std::iter::repeat;
pub enum Column { pub enum Column {
Permissions, Permissions,
FileName, 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 // 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 // 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, // padding to apply, rather than the width the text should end up,
@ -61,8 +67,8 @@ impl Column {
impl Alignment { impl Alignment {
pub fn pad_string(&self, string: &String, padding: uint) -> String { pub fn pad_string(&self, string: &String, padding: uint) -> String {
match *self { match *self {
Alignment::Left => format!("{}{}", string, " ".repeat(padding).as_slice()), Alignment::Left => format!("{}{}", string, spaces(padding).as_slice()),
Alignment::Right => format!("{}{}", " ".repeat(padding), string.as_slice()), Alignment::Right => format!("{}{}", spaces(padding), string.as_slice()),
} }
} }
} }

View File

@ -72,7 +72,7 @@ impl Options {
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println!("exa - ls with more features\n\n{}", getopts::usage("Usage:\n exa [options] [files...]", &opts)) println!("exa - ls with more features\n\n{}", getopts::usage("Usage:\n exa [options] [files...]", &opts));
return Err(2); return Err(2);
} }