Upgrade to latest Rust nightly

- s/to_owned/to_string/g
- TotalEq/TotalOrd changes
- snake_case of identifiers
This commit is contained in:
Ben S 2014-06-02 21:02:06 +01:00
parent 5abd53742e
commit 2d41333117
5 changed files with 14 additions and 14 deletions

View File

@ -28,18 +28,18 @@ pub struct StyleStruct {
impl Style {
pub fn paint(&self, input: &str) -> String {
match *self {
Plain => input.to_strbuf(),
Plain => input.to_string(),
Foreground(c) => c.paint(input),
Style(s) => match s {
StyleStruct { foreground, background, bold, underline } => {
let bg = match background {
Some(c) => format!("{};", c as int + 10),
None => "".to_strbuf()
None => "".to_string()
};
let bo = if bold { "1;" } else { "" };
let un = if underline { "4;" } else { "" };
let painted = format!("\x1B[{}{}{}{}m{}\x1B[0m", bo, un, bg, foreground as int, input.to_strbuf());
return painted.to_owned();
let painted = format!("\x1B[{}{}{}{}m{}\x1B[0m", bo, un, bg, foreground as int, input.to_string());
return painted.to_string();
}
}
}
@ -78,7 +78,7 @@ impl Colour {
// to turn Blue into a Style.
pub fn paint(&self, input: &str) -> String {
let re = format!("\x1B[{}m{}\x1B[0m", *self as int, input);
return re.to_owned();
return re.to_string();
}
pub fn underline(&self) -> Style {
@ -100,5 +100,5 @@ impl Colour {
pub fn strip_formatting(input: &String) -> String {
let re = regex!("\x1B\\[.+?m");
re.replace_all(input.as_slice(), "").to_owned()
re.replace_all(input.as_slice(), "").to_string()
}

2
exa.rs
View File

@ -26,7 +26,7 @@ fn main() {
// Default to listing the current directory when a target
// isn't specified (mimic the behaviour of ls)
let strs = if opts.dirs.is_empty() {
vec!(".".to_strbuf())
vec!(".".to_string())
}
else {
opts.dirs.clone()

View File

@ -101,12 +101,12 @@ impl<'a> File<'a> {
fn type_char(&self) -> String {
return match self.stat.kind {
io::TypeFile => ".".to_strbuf(),
io::TypeFile => ".".to_string(),
io::TypeDirectory => Blue.paint("d"),
io::TypeNamedPipe => Yellow.paint("|"),
io::TypeBlockSpecial => Purple.paint("s"),
io::TypeSymlink => Cyan.paint("l"),
_ => "?".to_owned(),
_ => "?".to_string(),
}
}

View File

@ -6,7 +6,7 @@ static IEC_PREFIXES: &'static [&'static str] = &[
"", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"
];
fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> String {
fn format_bytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> String {
let mut prefix = 0;
while amount > kilo {
amount /= kilo;
@ -16,9 +16,9 @@ fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> String {
}
pub fn format_IEC_bytes(amount: u64) -> String {
formatBytes(amount, 1024, IEC_PREFIXES)
format_bytes(amount, 1024, IEC_PREFIXES)
}
pub fn format_metric_bytes(amount: u64) -> String {
formatBytes(amount, 1000, METRIC_PREFIXES)
format_bytes(amount, 1000, METRIC_PREFIXES)
}

View File

@ -9,7 +9,7 @@ use std::ascii::StrAsciiExt;
// comparing based on those parts. A SortPart derives TotalOrd, so a
// Vec<SortPart> will automatically have natural sorting.
#[deriving(Eq, Ord, TotalEq, TotalOrd)]
#[deriving(Eq, Ord, PartialEq, PartialOrd)]
pub enum SortPart {
Numeric(u64),
Stringular(String),
@ -18,7 +18,7 @@ pub enum SortPart {
impl SortPart {
pub fn from_string(is_digit: bool, slice: &str) -> SortPart {
if is_digit {
Numeric(from_str::<u64>(slice).expect(slice.to_owned()))
Numeric(from_str::<u64>(slice).expect(slice.to_string()))
} else {
Stringular(slice.to_ascii_lower())
}