提交 05b2d541 编写于 作者: B Ben S

s/StrBuf/String/g

上级 566ed0bb
......@@ -16,7 +16,7 @@ pub struct StyleStruct {
}
impl Style {
pub fn paint(&self, input: &str) -> StrBuf {
pub fn paint(&self, input: &str) -> String {
match *self {
Plain => input.to_strbuf(),
Foreground(c) => c.paint(input),
......@@ -63,7 +63,7 @@ impl Style {
}
impl Colour {
pub fn paint(&self, input: &str) -> StrBuf {
pub fn paint(&self, input: &str) -> String {
let re = format!("\x1B[{}m{}\x1B[0m", *self as int, input);
return re.to_owned();
}
......@@ -85,7 +85,7 @@ impl Colour {
}
}
pub fn strip_formatting(input: &StrBuf) -> StrBuf {
pub fn strip_formatting(input: &String) -> String {
let re = regex!("\x1B\\[.+?m");
re.replace_all(input.as_slice(), "").to_owned()
}
......@@ -51,7 +51,7 @@ fn exa(options: &Options, path: Path) {
let columns = options.columns();
let table: Vec<Vec<StrBuf>> = files.iter()
let table: Vec<Vec<String>> = files.iter()
.filter(|&f| options.show(f))
.map(|f| columns.iter().map(|c| f.display(c)).collect())
.collect();
......
......@@ -55,7 +55,7 @@ impl<'a> File<'a> {
self.name.starts_with(".")
}
pub fn display(&self, column: &Column) -> StrBuf {
pub fn display(&self, column: &Column) -> String {
match *column {
Permissions => self.permissions(),
FileName => self.file_colour().paint(self.name.as_slice()),
......@@ -65,7 +65,7 @@ impl<'a> File<'a> {
}
}
fn file_size(&self, si: bool) -> StrBuf {
fn file_size(&self, si: bool) -> String {
// 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 {
......@@ -81,7 +81,7 @@ impl<'a> File<'a> {
}
}
fn type_char(&self) -> StrBuf {
fn type_char(&self) -> String {
return match self.stat.kind {
io::TypeFile => ".".to_strbuf(),
io::TypeDirectory => Blue.paint("d"),
......@@ -116,7 +116,7 @@ impl<'a> File<'a> {
}
}
fn permissions(&self) -> StrBuf {
fn permissions(&self) -> String {
let bits = self.stat.perm;
return format!("{}{}{}{}{}{}{}{}{}{}",
self.type_char(),
......@@ -133,7 +133,7 @@ impl<'a> File<'a> {
}
}
fn bit(bits: io::FilePermission, bit: io::FilePermission, other: &'static str, style: Style) -> StrBuf {
fn bit(bits: io::FilePermission, bit: io::FilePermission, other: &'static str, style: Style) -> String {
if bits.contains(bit) {
style.paint(other.as_slice())
} else {
......
......@@ -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]) -> StrBuf {
fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> String {
let mut prefix = 0;
while amount > kilo {
amount /= kilo;
......@@ -15,10 +15,10 @@ fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> StrBuf {
format!("{}{}", amount, prefixes[prefix])
}
pub fn formatBinaryBytes(amount: u64) -> StrBuf {
pub fn formatBinaryBytes(amount: u64) -> String {
formatBytes(amount, 1024, IEC_PREFIXES)
}
pub fn formatDecimalBytes(amount: u64) -> StrBuf {
pub fn formatDecimalBytes(amount: u64) -> String {
formatBytes(amount, 1000, METRIC_PREFIXES)
}
......@@ -12,11 +12,11 @@ pub struct Options {
pub showInvisibles: bool,
pub sortField: SortField,
pub reverse: bool,
pub dirs: Vec<StrBuf>,
pub dirs: Vec<String>,
}
impl SortField {
pub fn from_word(word: StrBuf) -> SortField {
pub fn from_word(word: String) -> SortField {
match word.as_slice() {
"name" => Name,
"size" => Size,
......@@ -39,7 +39,7 @@ impl SortField {
}
impl Options {
pub fn getopts(args: Vec<StrBuf>) -> Result<Options, getopts::Fail_> {
pub fn getopts(args: Vec<String>) -> Result<Options, getopts::Fail_> {
let opts = ~[
getopts::optflag("a", "all", "show dot-files"),
getopts::optflag("r", "reverse", "reverse order of files"),
......
......@@ -34,7 +34,7 @@ mod c {
}
}
pub fn get_user_name(uid: i32) -> Option<StrBuf> {
pub fn get_user_name(uid: i32) -> Option<String> {
let pw = unsafe { c::getpwuid(uid) };
if pw.is_not_null() {
return unsafe { Some(from_c_str(read(pw).pw_name)) };
......@@ -44,7 +44,7 @@ pub fn get_user_name(uid: i32) -> Option<StrBuf> {
}
}
pub fn get_group_name(gid: u32) -> Option<StrBuf> {
pub fn get_group_name(gid: u32) -> Option<String> {
let gr = unsafe { c::getgrgid(gid) };
if gr.is_not_null() {
return unsafe { Some(from_c_str(read(gr).gr_name)) };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册