Upgrade to latest Rust

I can't complain, because the breaking changes were caused by my pull request...
This commit is contained in:
Ben S 2014-12-02 14:20:28 +00:00
parent c217dce73d
commit 6134096586
3 changed files with 23 additions and 18 deletions

View File

@ -6,7 +6,7 @@ extern crate unicode;
use std::os; use std::os;
use std::io::fs; use std::io::fs;
use std::io::FileType::TypeDirectory; use std::io::FileType;
use std::iter::AdditiveIterator; use std::iter::AdditiveIterator;
use std::str::StrVector; use std::str::StrVector;
@ -17,7 +17,8 @@ use column::Alignment::Left;
use options::{Options, View}; use options::{Options, View};
use unix::Unix; use unix::Unix;
use ansi_term::{Plain, strip_formatting}; use ansi_term::Style::Plain;
use ansi_term::strip_formatting;
pub mod column; pub mod column;
pub mod dir; pub mod dir;
@ -49,7 +50,7 @@ fn exa(opts: &Options) {
let path = Path::new(file); let path = Path::new(file);
match fs::stat(&path) { match fs::stat(&path) {
Ok(stat) => { Ok(stat) => {
if !opts.list_dirs && stat.kind == TypeDirectory { if !opts.list_dirs && stat.kind == FileType::Directory {
dirs.push(file.clone()); dirs.push(file.clone());
} }
else { else {

View File

@ -1,7 +1,9 @@
use std::io::{fs, IoResult}; use std::io::{fs, IoResult};
use std::io; use std::io;
use ansi_term::{ANSIString, Colour, Plain, Style, Red, Green, Yellow, Blue, Purple, Cyan, Fixed}; use ansi_term::{ANSIString, Colour, Style};
use ansi_term::Style::Plain;
use ansi_term::Colour::{Red, Green, Yellow, Blue, Purple, Cyan, Fixed};
use column::Column; use column::Column;
use column::Column::*; use column::Column::*;
@ -128,7 +130,7 @@ impl<'a> File<'a> {
}, },
Blocks => { Blocks => {
if self.stat.kind == io::TypeFile || self.stat.kind == io::TypeSymlink { if self.stat.kind == io::FileType::RegularFile || self.stat.kind == io::FileType::Symlink {
Cyan.paint(self.stat.unstable.blocks.to_string().as_slice()).to_string() Cyan.paint(self.stat.unstable.blocks.to_string().as_slice()).to_string()
} }
else { else {
@ -159,7 +161,7 @@ impl<'a> File<'a> {
pub fn file_name(&self) -> String { pub fn file_name(&self) -> String {
let name = self.name.as_slice(); let name = self.name.as_slice();
let displayed_name = self.file_colour().paint(name); let displayed_name = self.file_colour().paint(name);
if self.stat.kind == io::TypeSymlink { if self.stat.kind == io::FileType::Symlink {
match fs::readlink(&self.path) { match fs::readlink(&self.path) {
Ok(path) => { Ok(path) => {
let target_path = match self.dir { let target_path = match self.dir {
@ -210,7 +212,7 @@ impl<'a> File<'a> {
fn file_size(&self, use_iec_prefixes: bool) -> String { fn file_size(&self, use_iec_prefixes: bool) -> String {
// Don't report file sizes for directories. I've never looked // Don't report file sizes for directories. I've never looked
// at one of those numbers and gained any information from it. // at one of those numbers and gained any information from it.
if self.stat.kind == io::TypeDirectory { if self.stat.kind == io::FileType::Directory {
GREY.paint("-").to_string() GREY.paint("-").to_string()
} }
else { else {
@ -227,12 +229,12 @@ impl<'a> File<'a> {
fn type_char(&self) -> ANSIString { fn type_char(&self) -> ANSIString {
return match self.stat.kind { return match self.stat.kind {
io::TypeFile => Plain.paint("."), io::FileType::RegularFile => Plain.paint("."),
io::TypeDirectory => Blue.paint("d"), io::FileType::Directory => Blue.paint("d"),
io::TypeNamedPipe => Yellow.paint("|"), io::FileType::NamedPipe => Yellow.paint("|"),
io::TypeBlockSpecial => Purple.paint("s"), io::FileType::BlockSpecial => Purple.paint("s"),
io::TypeSymlink => Cyan.paint("l"), io::FileType::Symlink => Cyan.paint("l"),
io::TypeUnknown => Plain.paint("?"), io::FileType::Unknown => Plain.paint("?"),
} }
} }
@ -241,7 +243,7 @@ impl<'a> File<'a> {
} }
fn has_multiple_links(&self) -> bool { fn has_multiple_links(&self) -> bool {
self.stat.kind == io::TypeFile && self.stat.unstable.nlink > 1 self.stat.kind == io::FileType::RegularFile && self.stat.unstable.nlink > 1
} }
fn permissions_string(&self) -> String { fn permissions_string(&self) -> String {

View File

@ -4,7 +4,9 @@ use self::FileType::*;
use std::io; use std::io;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use ansi_term::{Plain, Style, Red, Green, Yellow, Blue, Cyan, Fixed}; use ansi_term::Style;
use ansi_term::Style::Plain;
use ansi_term::Colour::{Red, Green, Yellow, Blue, Cyan, Fixed};
pub enum FileType { pub enum FileType {
Normal, Directory, Executable, Immediate, Compiled, Symlink, Special, Normal, Directory, Executable, Immediate, Compiled, Symlink, Special,
@ -79,13 +81,13 @@ pub trait HasType {
impl<'a> HasType for File<'a> { impl<'a> HasType for File<'a> {
fn get_type(&self) -> FileType { fn get_type(&self) -> FileType {
let name = self.name.as_slice(); let name = self.name.as_slice();
if self.stat.kind == io::TypeDirectory { if self.stat.kind == io::FileType::Directory {
return Directory; return Directory;
} }
else if self.stat.kind == io::TypeSymlink { else if self.stat.kind == io::FileType::Symlink {
return Symlink; return Symlink;
} }
else if self.stat.kind == io::TypeBlockSpecial || self.stat.kind == io::TypeNamedPipe || self.stat.kind == io::TypeUnknown { else if self.stat.kind == io::FileType::BlockSpecial || self.stat.kind == io::FileType::NamedPipe || self.stat.kind == io::FileType::Unknown {
return Special; return Special;
} }
else if self.stat.perm.contains(io::USER_EXECUTE) { else if self.stat.perm.contains(io::USER_EXECUTE) {