提交 4cbc1f06 编写于 作者: B Ben S

Upgrade to latest Rust nightly

- Lifetime changes in unix.rs
- lexical_ordering -> cmp
- from_utf8_lossy got moved into String
- vec.get(n) -> vec[n]
上级 90099f28
......@@ -89,7 +89,7 @@ fn grid_view(options: &Options, across: bool, dir: Dir) {
continue;
}
let file = files.get(num);
let file = files[num];
let file_name = file.name.clone();
let styled_name = file.file_colour().paint(file_name.as_slice());
if x == num_columns - 1 {
......@@ -134,7 +134,7 @@ fn lines_view(options: &Options, columns: &Vec<Column>, dir: Dir) {
.collect();
let column_widths: Vec<uint> = range(0, columns.len())
.map(|n| lengths.iter().map(|row| *row.get(n)).max().unwrap())
.map(|n| lengths.iter().map(|row| row[n]).max().unwrap())
.collect();
for (field_widths, row) in lengths.iter().zip(table.iter()) {
......@@ -147,7 +147,7 @@ fn lines_view(options: &Options, columns: &Vec<Column>, dir: Dir) {
print!("{}", row.get(num));
}
else {
let padding = *column_widths.get(num) - *field_widths.get(num);
let padding = column_widths[num] - field_widths[num];
print!("{}", column.alignment().pad_string(row.get(num), padding));
}
}
......
use std::io::{fs, IoResult};
use std::io;
use std::str::from_utf8_lossy;
use ansi_term::{Paint, Colour, Plain, Style, Red, Green, Yellow, Blue, Purple, Cyan, Fixed};
......@@ -32,7 +31,7 @@ pub struct File<'a> {
impl<'a> File<'a> {
pub fn from_path(path: &'a Path, parent: &'a Dir) -> IoResult<File<'a>> {
let v = path.filename().unwrap(); // fails if / or . or ..
let filename = from_utf8_lossy(v).to_string();
let filename = String::from_utf8_lossy(v).to_string();
// Use lstat here instead of file.stat(), as it doesn't follow
// symbolic links. Otherwise, the stat() call will fail if it
......@@ -160,7 +159,7 @@ impl<'a> File<'a> {
fn target_file_name_and_arrow(&self, target_path: Path) -> String {
let v = target_path.filename().unwrap();
let filename = from_utf8_lossy(v).to_string();
let filename = String::from_utf8_lossy(v).to_string();
let link_target = fs::stat(&target_path).map(|stat| File {
path: &target_path,
......
extern crate getopts;
use file::File;
use std::cmp::lexical_ordering;
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks, Inode, Blocks};
use std::ascii::StrAsciiExt;
......@@ -122,7 +121,7 @@ impl Options {
Extension => files.sort_by(|a, b| {
let exts = a.ext.clone().map(|e| e.as_slice().to_ascii_lower()).cmp(&b.ext.clone().map(|e| e.as_slice().to_ascii_lower()));
let names = a.name.as_slice().to_ascii_lower().cmp(&b.name.as_slice().to_ascii_lower());
lexical_ordering(exts, names)
exts.cmp(&names)
}),
}
......
......@@ -50,7 +50,8 @@ pub struct Unix {
impl Unix {
pub fn empty_cache() -> Unix {
let uid = unsafe { c::getuid() };
let info = unsafe { c::getpwuid(uid as i32).to_option().unwrap() }; // the user has to have a name
let infoptr = unsafe { c::getpwuid(uid as i32) };
let info = unsafe { infoptr.to_option().unwrap() }; // the user has to have a name
let username = unsafe { from_c_str(info.pw_name) };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册