From 4cbc1f063a7494fe78c63b8656f25ea07f9365d9 Mon Sep 17 00:00:00 2001 From: Ben S Date: Mon, 21 Jul 2014 22:05:04 +0100 Subject: [PATCH] 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] --- src/exa.rs | 6 +++--- src/file.rs | 5 ++--- src/options.rs | 3 +-- src/unix.rs | 3 ++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/exa.rs b/src/exa.rs index ff7e3ea..c36d7d4 100644 --- a/src/exa.rs +++ b/src/exa.rs @@ -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, dir: Dir) { .collect(); let column_widths: Vec = 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, 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)); } } diff --git a/src/file.rs b/src/file.rs index 4a218ae..69c0b90 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1,6 +1,5 @@ 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> { 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, diff --git a/src/options.rs b/src/options.rs index 35f0ca7..750c423 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,7 +1,6 @@ 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) }), } diff --git a/src/unix.rs b/src/unix.rs index 4d6d567..a14a1bb 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -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) };