diff --git a/build.rs b/build.rs index 239d762..ea0de1d 100644 --- a/build.rs +++ b/build.rs @@ -12,7 +12,7 @@ extern crate datetime; use std::env; -use std::io::Result as IOResult; +use std::io; fn git_hash() -> String { @@ -46,7 +46,7 @@ fn build_date() -> String { format!("{}", now.date().iso()) } -fn write_statics() -> IOResult<()> { +fn write_statics() -> io::Result<()> { use std::fs::File; use std::io::Write; use std::path::PathBuf; diff --git a/src/fs/dir.rs b/src/fs/dir.rs index a1e93c6..7f7b067 100644 --- a/src/fs/dir.rs +++ b/src/fs/dir.rs @@ -1,6 +1,6 @@ use crate::fs::feature::git::GitCache; use crate::fs::fields::GitStatus; -use std::io::{self, Result as IOResult}; +use std::io; use std::fs; use std::path::{Path, PathBuf}; use std::slice::Iter as SliceIter; @@ -35,7 +35,7 @@ impl Dir { /// The `read_dir` iterator doesn’t actually yield the `.` and `..` /// entries, so if the user wants to see them, we’ll have to add them /// ourselves after the files have been read. - pub fn read_dir(path: PathBuf) -> IOResult { + pub fn read_dir(path: PathBuf) -> io::Result { info!("Reading directory {:?}", &path); let contents = fs::read_dir(&path)? diff --git a/src/fs/file.rs b/src/fs/file.rs index dce5219..cad93d2 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -1,7 +1,6 @@ //! Files, and methods and fields to access their metadata. -use std::io::Error as IOError; -use std::io::Result as IOResult; +use std::io; use std::os::unix::fs::{FileTypeExt, MetadataExt, PermissionsExt}; use std::path::{Path, PathBuf}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; @@ -67,7 +66,7 @@ pub struct File<'dir> { } impl<'dir> File<'dir> { - pub fn from_args(path: PathBuf, parent_dir: PD, filename: FN) -> IOResult> + pub fn from_args(path: PathBuf, parent_dir: PD, filename: FN) -> io::Result> where PD: Into>, FN: Into> { @@ -82,7 +81,7 @@ impl<'dir> File<'dir> { Ok(File { path, parent_dir, metadata, ext, name, is_all_all }) } - pub fn new_aa_current(parent_dir: &'dir Dir) -> IOResult> { + pub fn new_aa_current(parent_dir: &'dir Dir) -> io::Result> { let path = parent_dir.path.to_path_buf(); let ext = File::ext(&path); @@ -94,7 +93,7 @@ impl<'dir> File<'dir> { Ok(File { path, parent_dir, metadata, ext, name: ".".into(), is_all_all }) } - pub fn new_aa_parent(path: PathBuf, parent_dir: &'dir Dir) -> IOResult> { + pub fn new_aa_parent(path: PathBuf, parent_dir: &'dir Dir) -> io::Result> { let ext = File::ext(&path); debug!("Statting file {:?}", &path); @@ -162,7 +161,7 @@ impl<'dir> File<'dir> { /// /// Returns an IO error upon failure, but this shouldn’t be used to check /// if a `File` is a directory or not! For that, just use `is_directory()`. - pub fn to_dir(&self) -> IOResult { + pub fn to_dir(&self) -> io::Result { Dir::read_dir(self.path.clone()) } @@ -459,10 +458,10 @@ pub enum FileTarget<'dir> { /// There was an IO error when following the link. This can happen if the /// file isn’t a link to begin with, but also if, say, we don’t have /// permission to follow it. - Err(IOError), + Err(io::Error), // Err is its own variant, instead of having the whole thing be inside an - // `IOResult`, because being unable to follow a symlink is not a serious + // `io::Result`, because being unable to follow a symlink is not a serious // error — we just display the error message and move on. } diff --git a/src/main.rs b/src/main.rs index 71e63e1..3694abc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use std::env; use std::ffi::{OsStr, OsString}; -use std::io::{stdout, Stdout, stderr, Write, Result as IOResult, ErrorKind}; +use std::io::{self, Write, ErrorKind}; use std::path::{Component, PathBuf}; use ansi_term::{ANSIStrings, Style}; @@ -40,7 +40,7 @@ fn main() { } let git = git_options(&options, &input_paths); - let writer = stdout(); + let writer = io::stdout(); let exa = Exa { options, writer, input_paths, git }; match exa.run() { @@ -88,7 +88,7 @@ pub struct Exa<'args> { pub options: Options, /// The output handle that we write to. - pub writer: Stdout, + pub writer: io::Stdout, /// List of the free command-line arguments that should correspond to file /// names (anything that isn’t an option). @@ -122,7 +122,7 @@ fn git_options(options: &Options, args: &[&OsStr]) -> Option { } impl<'args> Exa<'args> { - pub fn run(mut self) -> IOResult { + pub fn run(mut self) -> io::Result { debug!("Running with options: {:#?}", self.options); let mut files = Vec::new(); @@ -133,14 +133,14 @@ impl<'args> Exa<'args> { match File::from_args(PathBuf::from(file_path), None, None) { Err(e) => { exit_status = 2; - writeln!(stderr(), "{:?}: {}", file_path, e)?; + writeln!(io::stderr(), "{:?}: {}", file_path, e)?; } Ok(f) => { if f.points_to_directory() && ! self.options.dir_action.treat_dirs_as_files() { match f.to_dir() { Ok(d) => dirs.push(d), - Err(e) => writeln!(stderr(), "{:?}: {}", file_path, e)?, + Err(e) => writeln!(io::stderr(), "{:?}: {}", file_path, e)?, } } else { @@ -163,7 +163,7 @@ impl<'args> Exa<'args> { self.print_dirs(dirs, no_files, is_only_dir, exit_status) } - fn print_dirs(&mut self, dir_files: Vec, mut first: bool, is_only_dir: bool, exit_status: i32) -> IOResult { + fn print_dirs(&mut self, dir_files: Vec, mut first: bool, is_only_dir: bool, exit_status: i32) -> io::Result { for dir in dir_files { // Put a gap between directories, or between the list of files and @@ -185,8 +185,8 @@ impl<'args> Exa<'args> { let git_ignore = self.options.filter.git_ignore == GitIgnore::CheckAndIgnore; for file in dir.files(self.options.filter.dot_filter, self.git.as_ref(), git_ignore) { match file { - Ok(file) => children.push(file), - Err((path, e)) => writeln!(stderr(), "[{}: {}]", path.display(), e)?, + Ok(file) => children.push(file), + Err((path, e)) => writeln!(io::stderr(), "[{}: {}]", path.display(), e)?, } }; @@ -200,15 +200,15 @@ impl<'args> Exa<'args> { let mut child_dirs = Vec::new(); for child_dir in children.iter().filter(|f| f.is_directory() && ! f.is_all_all) { match child_dir.to_dir() { - Ok(d) => child_dirs.push(d), - Err(e) => writeln!(stderr(), "{}: {}", child_dir.path.display(), e)?, + Ok(d) => child_dirs.push(d), + Err(e) => writeln!(io::stderr(), "{}: {}", child_dir.path.display(), e)?, } } self.print_files(Some(&dir), children)?; match self.print_dirs(child_dirs, false, false, exit_status) { - Ok(_) => (), - Err(e) => return Err(e), + Ok(_) => (), + Err(e) => return Err(e), } continue; } @@ -223,7 +223,7 @@ impl<'args> Exa<'args> { /// Prints the list of files using whichever view is selected. /// For various annoying logistical reasons, each one handles /// printing differently... - fn print_files(&mut self, dir: Option<&Dir>, files: Vec) -> IOResult<()> { + fn print_files(&mut self, dir: Option<&Dir>, files: Vec) -> io::Result<()> { if files.is_empty() { return Ok(()); } diff --git a/src/output/details.rs b/src/output/details.rs index af68850..16e298c 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -60,7 +60,7 @@ //! can be displayed, in order to make sure that every column is wide enough. -use std::io::{Write, Error as IOError, Result as IOResult}; +use std::io::{self, Write}; use std::mem::MaybeUninit; use std::path::PathBuf; use std::vec::IntoIter as VecIntoIter; @@ -135,7 +135,7 @@ pub struct Render<'a> { struct Egg<'a> { table_row: Option, xattrs: Vec, - errors: Vec<(IOError, Option)>, + errors: Vec<(io::Error, Option)>, dir: Option, file: &'a File<'a>, icon: Option, @@ -149,7 +149,7 @@ impl<'a> AsRef> for Egg<'a> { impl<'a> Render<'a> { - pub fn render(self, mut git: Option<&'a GitCache>, w: &mut W) -> IOResult<()> { + pub fn render(self, mut git: Option<&'a GitCache>, w: &mut W) -> io::Result<()> { let mut pool = Pool::new(num_cpus::get() as u32); let mut rows = Vec::new(); @@ -357,7 +357,7 @@ impl<'a> Render<'a> { } } - fn render_error(&self, error: &IOError, tree: TreeParams, path: Option) -> Row { + fn render_error(&self, error: &io::Error, tree: TreeParams, path: Option) -> Row { use crate::output::file_name::Colours; let error_message = match path { diff --git a/src/output/grid.rs b/src/output/grid.rs index b560b46..478591b 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -1,4 +1,4 @@ -use std::io::{Write, Result as IOResult}; +use std::io::{self, Write}; use term_grid as tg; @@ -32,7 +32,7 @@ pub struct Render<'a> { } impl<'a> Render<'a> { - pub fn render(&self, w: &mut W) -> IOResult<()> { + pub fn render(&self, w: &mut W) -> io::Result<()> { let mut grid = tg::Grid::new(tg::GridOptions { direction: self.opts.direction(), filling: tg::Filling::Spaces(2), diff --git a/src/output/grid_details.rs b/src/output/grid_details.rs index 05cb006..a0aaef3 100644 --- a/src/output/grid_details.rs +++ b/src/output/grid_details.rs @@ -1,6 +1,6 @@ //! The grid-details view lists several details views side-by-side. -use std::io::{Write, Result as IOResult}; +use std::io::{self, Write}; use ansi_term::{ANSIGenericString, ANSIStrings}; use term_grid as grid; @@ -119,7 +119,7 @@ impl<'a> Render<'a> { // This doesn’t take an IgnoreCache even though the details one does // because grid-details has no tree view. - pub fn render(self, git: Option<&GitCache>, w: &mut W) -> IOResult<()> { + pub fn render(self, git: Option<&GitCache>, w: &mut W) -> io::Result<()> { if let Some((grid, width)) = self.find_fitting_grid(git) { write!(w, "{}", grid.fit_into_columns(width)) } diff --git a/src/output/lines.rs b/src/output/lines.rs index cc2bd9a..6bc4fae 100644 --- a/src/output/lines.rs +++ b/src/output/lines.rs @@ -1,4 +1,4 @@ -use std::io::{Write, Result as IOResult}; +use std::io::{self, Write}; use ansi_term::{ANSIStrings, ANSIGenericString}; @@ -23,7 +23,7 @@ pub struct Render<'a> { } impl<'a> Render<'a> { - pub fn render(&self, w: &mut W) -> IOResult<()> { + pub fn render(&self, w: &mut W) -> io::Result<()> { for file in &self.files { let name_cell = self.render_file(file).paint(); if self.opts.icons {