summaryrefslogtreecommitdiffstats
path: root/src/file.rs
diff options
context:
space:
mode:
authorBen S <ogham@bsago.me>2014-11-26 07:36:09 +0000
committerBen S <ogham@bsago.me>2014-11-26 07:36:09 +0000
commit05dd644c92ed32ad29117f5ea01bad94e07e9067 (patch)
tree3da2ce1ae10e0fd1f10df59ef9fd7541c48a842b /src/file.rs
parent6ade060eb687f8f062f221dbcb36e4e4cf11ef8a (diff)
Upgrade to latest ansi_term
Yeah, I broke my own code again.
Diffstat (limited to 'src/file.rs')
-rw-r--r--src/file.rs37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/file.rs b/src/file.rs
index 4cd7ed9..460cac6 100644
--- a/src/file.rs
+++ b/src/file.rs
@@ -1,8 +1,7 @@
use std::io::{fs, IoResult};
use std::io;
-use std::str::SendStr;
-use ansi_term::{Paint, Colour, Plain, Style, Red, Green, Yellow, Blue, Purple, Cyan, Fixed};
+use ansi_term::{ANSIString, Colour, Plain, Style, Red, Green, Yellow, Blue, Purple, Cyan, Fixed};
use column::Column;
use column::Column::*;
@@ -121,19 +120,19 @@ impl<'a> File<'a> {
// the time.
HardLinks => {
let style = if self.has_multiple_links() { Red.on(Yellow) } else { Red.normal() };
- style.paint(self.stat.unstable.nlink.to_string().as_slice())
+ style.paint(self.stat.unstable.nlink.to_string().as_slice()).to_string()
},
Inode => {
- Purple.paint(self.stat.unstable.inode.to_string().as_slice())
+ Purple.paint(self.stat.unstable.inode.to_string().as_slice()).to_string()
},
Blocks => {
if self.stat.kind == io::TypeFile || self.stat.kind == io::TypeSymlink {
- Cyan.paint(self.stat.unstable.blocks.to_string().as_slice())
+ Cyan.paint(self.stat.unstable.blocks.to_string().as_slice()).to_string()
}
else {
- GREY.paint("-")
+ GREY.paint("-").to_string()
}
},
@@ -144,7 +143,7 @@ impl<'a> File<'a> {
unix.load_user(uid);
let user_name = unix.get_user_name(uid).unwrap_or(uid.to_string());
let style = if unix.uid == uid { Yellow.bold() } else { Plain };
- style.paint(user_name.as_slice())
+ style.paint(user_name.as_slice()).to_string()
},
Group => {
@@ -152,7 +151,7 @@ impl<'a> File<'a> {
unix.load_group(gid);
let group_name = unix.get_group_name(gid).unwrap_or(gid.to_string());
let style = if unix.is_group_member(gid) { Yellow.normal() } else { Plain };
- style.paint(group_name.as_slice())
+ style.paint(group_name.as_slice()).to_string()
},
}
}
@@ -169,11 +168,11 @@ impl<'a> File<'a> {
};
format!("{} {}", displayed_name, self.target_file_name_and_arrow(target_path))
}
- Err(_) => displayed_name,
+ Err(_) => displayed_name.to_string(),
}
}
else {
- displayed_name
+ displayed_name.to_string()
}
}
@@ -212,7 +211,7 @@ impl<'a> File<'a> {
// Don't report file sizes for directories. I've never looked
// at one of those numbers and gained any information from it.
if self.stat.kind == io::TypeDirectory {
- GREY.paint("-")
+ GREY.paint("-").to_string()
}
else {
let (size, suffix) = if use_iec_prefixes {
@@ -226,14 +225,14 @@ impl<'a> File<'a> {
}
}
- fn type_char(&self) -> SendStr {
+ fn type_char(&self) -> ANSIString {
return match self.stat.kind {
- io::TypeFile => ".".into_maybe_owned(),
- io::TypeDirectory => Blue.paint("d").into_maybe_owned(),
- io::TypeNamedPipe => Yellow.paint("|").into_maybe_owned(),
- io::TypeBlockSpecial => Purple.paint("s").into_maybe_owned(),
- io::TypeSymlink => Cyan.paint("l").into_maybe_owned(),
- io::TypeUnknown => "?".into_maybe_owned(),
+ io::TypeFile => Plain.paint("."),
+ io::TypeDirectory => Blue.paint("d"),
+ io::TypeNamedPipe => Yellow.paint("|"),
+ io::TypeBlockSpecial => Purple.paint("s"),
+ io::TypeSymlink => Cyan.paint("l"),
+ io::TypeUnknown => Plain.paint("?"),
}
}
@@ -264,7 +263,7 @@ impl<'a> File<'a> {
);
}
- fn permission_bit(bits: io::FilePermission, bit: io::FilePermission, character: &'static str, style: Style) -> String {
+ fn permission_bit(bits: io::FilePermission, bit: io::FilePermission, character: &'static str, style: Style) -> ANSIString {
if bits.contains(bit) {
style.paint(character.as_slice())
}