New set of lints, and Rust 2018 idioms

This commit is contained in:
Benjamin Sago 2020-10-13 01:36:41 +01:00
parent f42957fab8
commit 3dc86c99ad
21 changed files with 73 additions and 69 deletions

View File

@ -1,7 +1,6 @@
//! Extended attribute support for Darwin and Linux systems.
#![allow(trivial_casts)] // for ARM
extern crate libc;
use std::cmp::Ordering;
use std::io;

View File

@ -91,7 +91,7 @@ pub struct FileFilter {
impl FileFilter {
/// Remove every file in the given vector that does *not* pass the
/// filter predicate for files found inside a directory.
pub fn filter_child_files(&self, files: &mut Vec<File>) {
pub fn filter_child_files(&self, files: &mut Vec<File<'_>>) {
files.retain(|f| ! self.ignore_patterns.is_ignored(&f.name));
if self.only_dirs {
@ -108,7 +108,7 @@ impl FileFilter {
/// dotfile, because its been directly specified. But running
/// `exa -I='*.ogg' music/*` should filter out the ogg files obtained
/// from the glob, even though the globbing is done by the shell!
pub fn filter_argument_files(&self, files: &mut Vec<File>) {
pub fn filter_argument_files(&self, files: &mut Vec<File<'_>>) {
files.retain(|f| {
! self.ignore_patterns.is_ignored(&f.name)
});
@ -240,7 +240,7 @@ impl SortField {
/// into groups between letters and numbers, and then sorts those blocks
/// together, so `file10` will sort after `file9`, instead of before it
/// because of the `1`.
pub fn compare_files(self, a: &File, b: &File) -> Ordering {
pub fn compare_files(self, a: &File<'_>, b: &File<'_>) -> Ordering {
use self::SortCase::{ABCabc, AaBbCc};
match self {

View File

@ -19,7 +19,7 @@ impl FileExtensions {
/// An “immediate” file is something that can be run or activated somehow
/// in order to kick off the build of a project. Its usually only present
/// in directories full of source code.
fn is_immediate(&self, file: &File) -> bool {
fn is_immediate(&self, file: &File<'_>) -> bool {
file.name.to_lowercase().starts_with("readme") ||
file.name.ends_with(".ninja") ||
file.name_is_one_of( &[
@ -30,7 +30,7 @@ impl FileExtensions {
])
}
fn is_image(&self, file: &File) -> bool {
fn is_image(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"png", "jpeg", "jpg", "gif", "bmp", "tiff", "tif",
"ppm", "pgm", "pbm", "pnm", "webp", "raw", "arw",
@ -39,33 +39,33 @@ impl FileExtensions {
])
}
fn is_video(&self, file: &File) -> bool {
fn is_video(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"avi", "flv", "m2v", "m4v", "mkv", "mov", "mp4", "mpeg",
"mpg", "ogm", "ogv", "vob", "wmv", "webm", "m2ts",
])
}
fn is_music(&self, file: &File) -> bool {
fn is_music(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"aac", "m4a", "mp3", "ogg", "wma", "mka", "opus",
])
}
// Lossless music, rather than any other kind of data...
fn is_lossless(&self, file: &File) -> bool {
fn is_lossless(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"alac", "ape", "flac", "wav",
])
}
fn is_crypto(&self, file: &File) -> bool {
fn is_crypto(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"asc", "enc", "gpg", "pgp", "sig", "signature", "pfx", "p12",
])
}
fn is_document(&self, file: &File) -> bool {
fn is_document(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"djvu", "doc", "docx", "dvi", "eml", "eps", "fotd", "key",
"keynote", "numbers", "odp", "odt", "pages", "pdf", "ppt",
@ -73,7 +73,7 @@ impl FileExtensions {
])
}
fn is_compressed(&self, file: &File) -> bool {
fn is_compressed(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"zip", "tar", "Z", "z", "gz", "bz2", "a", "ar", "7z",
"iso", "dmg", "tc", "rar", "par", "tgz", "xz", "txz",
@ -81,13 +81,13 @@ impl FileExtensions {
])
}
fn is_temp(&self, file: &File) -> bool {
fn is_temp(&self, file: &File<'_>) -> bool {
file.name.ends_with('~')
|| (file.name.starts_with('#') && file.name.ends_with('#'))
|| file.extension_is_one_of( &[ "tmp", "swp", "swo", "swn", "bak", "bk" ])
}
fn is_compiled(&self, file: &File) -> bool {
fn is_compiled(&self, file: &File<'_>) -> bool {
if file.extension_is_one_of( &[ "class", "elc", "hi", "o", "pyc", "zwc", "ko" ]) {
true
}
@ -101,7 +101,7 @@ impl FileExtensions {
}
impl FileColours for FileExtensions {
fn colour_file(&self, file: &File) -> Option<Style> {
fn colour_file(&self, file: &File<'_>) -> Option<Style> {
use ansi_term::Colour::*;
Some(match file {
@ -121,7 +121,7 @@ impl FileColours for FileExtensions {
}
impl FileIcon for FileExtensions {
fn icon_file(&self, file: &File) -> Option<char> {
fn icon_file(&self, file: &File<'_>) -> Option<char> {
use crate::output::icons::Icons;
if self.is_music(file) || self.is_lossless(file) {

View File

@ -1,5 +1,10 @@
#![warn(deprecated_in_future)]
#![warn(future_incompatible)]
#![warn(nonstandard_style)]
#![warn(rust_2018_compatibility)]
#![warn(rust_2018_idioms)]
#![warn(trivial_casts, trivial_numeric_casts)]
#![warn(unused_results)]
#![warn(unused)]
use std::env;
use std::ffi::{OsStr, OsString};
@ -223,7 +228,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<File>) -> io::Result<()> {
fn print_files(&mut self, dir: Option<&Dir>, files: Vec<File<'_>>) -> io::Result<()> {
if files.is_empty() {
return Ok(());
}

View File

@ -12,7 +12,7 @@ impl DirAction {
/// There are three possible actions, and they overlap somewhat: the
/// `--tree` flag is another form of recursion, so those two are allowed
/// to both be present, but the `--list-dirs` flag is used separately.
pub fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let recurse = matches.has(&flags::RECURSE)?;
let as_file = matches.has(&flags::LIST_DIRS)?;
let tree = matches.has(&flags::TREE)?;
@ -52,7 +52,7 @@ impl RecurseOptions {
/// flags value, and whether the `--tree` flag was passed, which was
/// determined earlier. The maximum level should be a number, and this
/// will fail with an `Err` if it isnt.
pub fn deduce(matches: &MatchedFlags, tree: bool) -> Result<Self, OptionsError> {
pub fn deduce(matches: &MatchedFlags<'_>, tree: bool) -> Result<Self, OptionsError> {
let max_depth = if let Some(level) = matches.get(&flags::LEVEL)? {
match level.to_string_lossy().parse() {
Ok(l) => Some(l),

View File

@ -50,7 +50,7 @@ impl From<glob::PatternError> for OptionsError {
}
impl fmt::Display for OptionsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use crate::options::parser::TakesValue;
match self {
@ -103,7 +103,7 @@ impl OptionsError {
pub struct Choices(pub &'static [&'static str]);
impl fmt::Display for Choices {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "choices: {}", self.0.join(", "))
}
}

View File

@ -10,7 +10,7 @@ use crate::options::parser::MatchedFlags;
impl FileFilter {
/// Determines which of all the file filter options to use.
pub fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
Ok(Self {
list_dirs_first: matches.has(&flags::DIRS_FIRST)?,
reverse: matches.has(&flags::REVERSE)?,
@ -29,7 +29,7 @@ impl SortField {
/// This arguments value can be one of several flags, listed above.
/// Returns the default sort field if none is given, or `Err` if the
/// value doesnt correspond to a sort field we know about.
fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let word = match matches.get(&flags::SORT)? {
Some(w) => w,
None => return Ok(Self::default()),
@ -153,7 +153,7 @@ impl DotFilter {
/// It also checks for the `--tree` option in strict mode, because of a
/// special case where `--tree --all --all` wont work: listing the
/// parent directory in tree mode would loop onto itself!
pub fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let count = matches.count(&flags::ALL);
if count == 0 {
@ -180,7 +180,7 @@ impl IgnorePatterns {
/// Determines the set of glob patterns to use based on the
/// `--ignore-glob` arguments value. This is a list of strings
/// separated by pipe (`|`) characters, given in any order.
pub fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
// If there are no inputs, we return a set of patterns that doesnt
// match anything, rather than, say, `None`.
@ -204,7 +204,7 @@ impl IgnorePatterns {
impl GitIgnore {
pub fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
if matches.has(&flags::GIT_IGNORE)? {
Ok(Self::CheckAndIgnore)
}

View File

@ -86,7 +86,7 @@ impl HelpString {
/// We dont do any strict-mode error checking here: its OK to give
/// the --help or --long flags more than once. Actually checking for
/// errors when the user wants help is kind of petty!
pub fn deduce(matches: &MatchedFlags) -> Option<Self> {
pub fn deduce(matches: &MatchedFlags<'_>) -> Option<Self> {
if matches.count(&flags::HELP) > 0 {
let only_long = matches.count(&flags::LONG) > 0;
let git = cfg!(feature="git");
@ -103,7 +103,7 @@ impl fmt::Display for HelpString {
/// Format this help options into an actual string of help
/// text to be displayed to the user.
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
writeln!(f, "Usage:\n exa [options] [files...]")?;
if ! self.only_long {

View File

@ -167,7 +167,7 @@ impl Options {
/// Determines the complete set of options based on the given command-line
/// arguments, after theyve been parsed.
fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<Self, OptionsError> {
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
let dir_action = DirAction::deduce(matches)?;
let filter = FileFilter::deduce(matches)?;
let view = View::deduce(matches, vars)?;
@ -214,7 +214,7 @@ pub mod test {
/// It returns a vector with one or two elements in.
/// These elements can then be tested with assert_eq or what have you.
pub fn parse_for_test<T, F>(inputs: &[&str], args: &'static [&'static Arg], strictnesses: Strictnesses, get: F) -> Vec<T>
where F: Fn(&MatchedFlags) -> T
where F: Fn(&MatchedFlags<'_>) -> T
{
use self::Strictnesses::*;
use crate::options::parser::{Args, Strictness};

View File

@ -68,7 +68,7 @@ impl Flag {
}
impl fmt::Display for Flag {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
Self::Short(short) => write!(f, "-{}", *short as char),
Self::Long(long) => write!(f, "--{}", long),
@ -123,7 +123,7 @@ pub struct Arg {
}
impl fmt::Display for Arg {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "--{}", self.long)?;
if let Some(short) = self.short {
@ -476,7 +476,7 @@ pub enum ParseError {
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NeedsValue { flag, values: None } => write!(f, "Flag {} needs a value", flag),
Self::NeedsValue { flag, values: Some(cs) } => write!(f, "Flag {} needs a value ({})", flag, Choices(cs)),

View File

@ -37,7 +37,7 @@ impl Default for TerminalColours {
impl TerminalColours {
/// Determine which terminal colour conditions to use.
fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let word = match matches.get_where(|f| f.matches(&flags::COLOR) || f.matches(&flags::COLOUR))? {
Some(w) => w,
None => return Ok(Self::default()),
@ -77,7 +77,7 @@ pub struct Styles {
impl Styles {
#[allow(trivial_casts)] // the `as Box<_>` stuff below warns about this for some reason
pub fn deduce<V, TW>(matches: &MatchedFlags, vars: &V, widther: TW) -> Result<Self, OptionsError>
pub fn deduce<V, TW>(matches: &MatchedFlags<'_>, vars: &V, widther: TW) -> Result<Self, OptionsError>
where TW: Fn() -> Option<usize>, V: Vars {
use crate::info::filetype::FileExtensions;
use crate::output::file_name::NoFileColours;
@ -185,7 +185,7 @@ struct ExtensionMappings {
use crate::output::file_name::FileColours;
impl FileColours for ExtensionMappings {
fn colour_file(&self, file: &File) -> Option<Style> {
fn colour_file(&self, file: &File<'_>) -> Option<Style> {
self.mappings.iter().rev()
.find(|t| t.0.matches(&file.name))
.map (|t| t.1)
@ -204,7 +204,7 @@ impl ExtensionMappings {
impl Classify {
fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let flagged = matches.has(&flags::CLASSIFY)?;
if flagged { Ok(Self::AddFileIndicators) }

View File

@ -19,7 +19,7 @@ impl VersionString {
/// deduce functions, returning Err if help needs to be shown.
///
/// Like --help, this doesnt check for errors.
pub fn deduce(matches: &MatchedFlags) -> Option<Self> {
pub fn deduce(matches: &MatchedFlags<'_>) -> Option<Self> {
if matches.count(&flags::VERSION) > 0 {
Some(Self)
}
@ -30,7 +30,7 @@ impl VersionString {
}
impl fmt::Display for VersionString {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "{}", include!(concat!(env!("OUT_DIR"), "/version_string.txt")))
}
}

View File

@ -12,7 +12,7 @@ use crate::output::time::TimeFormat;
impl View {
/// Determine which view to use and all of that views arguments.
pub fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<Self, OptionsError> {
pub fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
use crate::options::style::Styles;
let mode = Mode::deduce(matches, vars)?;
@ -25,7 +25,7 @@ impl View {
impl Mode {
/// Determine the mode from the command-line arguments.
pub fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<Self, OptionsError> {
pub fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
let long = || {
if matches.has(&flags::ACROSS)? && ! matches.has(&flags::GRID)? {
Err(OptionsError::Useless(&flags::ACROSS, true, &flags::LONG))
@ -207,7 +207,7 @@ impl RowThreshold {
impl TableOptions {
fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<Self, OptionsError> {
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
let time_format = TimeFormat::deduce(matches, vars)?;
let size_format = SizeFormat::deduce(matches)?;
let columns = Columns::deduce(matches)?;
@ -217,7 +217,7 @@ impl TableOptions {
impl Columns {
fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let time_types = TimeTypes::deduce(matches)?;
let git = cfg!(feature = "git") && matches.has(&flags::GIT)?;
@ -246,7 +246,7 @@ impl SizeFormat {
/// strings of digits in your head. Changing the format to anything else
/// involves the `--binary` or `--bytes` flags, and these conflict with
/// each other.
fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let flag = matches.has_where(|f| f.matches(&flags::BINARY) || f.matches(&flags::BYTES))?;
Ok(match flag {
@ -261,7 +261,7 @@ impl SizeFormat {
impl TimeFormat {
/// Determine how time should be formatted in timestamp columns.
fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<Self, OptionsError> {
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
let word = match matches.get(&flags::TIME_STYLE)? {
Some(w) => {
w.to_os_string()
@ -306,7 +306,7 @@ impl TimeTypes {
/// Its valid to show more than one column by passing in more than one
/// option, but passing *no* options means that the user just wants to
/// see the default set.
fn deduce(matches: &MatchedFlags) -> Result<Self, OptionsError> {
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let possible_word = matches.get(&flags::TIME)?;
let modified = matches.has(&flags::MODIFIED)?;
let changed = matches.has(&flags::CHANGED)?;

View File

@ -157,7 +157,7 @@ impl TextCellContents {
/// Produces an `ANSIStrings` value that can be used to print the styled
/// values of this cell as an ANSI-terminal-formatted string.
pub fn strings(&self) -> ANSIStrings {
pub fn strings(&self) -> ANSIStrings<'_> {
ANSIStrings(&self.0)
}

View File

@ -276,7 +276,7 @@ impl<'a> Render<'a> {
});
// this is safe because all entries have been initialized above
let mut file_eggs = unsafe { std::mem::transmute::<_, Vec<Egg>>(file_eggs) };
let mut file_eggs = unsafe { std::mem::transmute::<_, Vec<Egg<'_>>>(file_eggs) };
self.filter.sort_files(&mut file_eggs);
for (tree_params, egg) in depth.iterate_over(file_eggs.into_iter()) {

View File

@ -76,7 +76,7 @@ impl Default for Classify {
/// A **file name** holds all the information necessary to display the name
/// of the given file. This is used in all of the views.
pub struct FileName<'a, 'dir: 'a, C: Colours+'a> {
pub struct FileName<'a, 'dir, C: Colours> {
/// A reference to the file that were getting the name of.
file: &'a File<'dir>,
@ -191,7 +191,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
/// Adds the bits of the parent path to the given bits vector.
/// The path gets its characters escaped based on the colours.
fn add_parent_bits(&self, bits: &mut Vec<ANSIString>, parent: &Path) {
fn add_parent_bits(&self, bits: &mut Vec<ANSIString<'_>>, parent: &Path) {
let coconut = parent.components().count();
if coconut == 1 && parent.has_root() {
@ -324,14 +324,14 @@ pub trait Colours: FiletypeColours {
// needs Debug because FileStyle derives it
pub trait FileColours: Debug + Sync {
fn colour_file(&self, file: &File) -> Option<Style>;
fn colour_file(&self, file: &File<'_>) -> Option<Style>;
}
#[derive(PartialEq, Debug)]
pub struct NoFileColours;
impl FileColours for NoFileColours {
fn colour_file(&self, _file: &File) -> Option<Style> {
fn colour_file(&self, _file: &File<'_>) -> Option<Style> {
None
}
}
@ -344,7 +344,7 @@ impl<A, B> FileColours for (A, B)
where A: FileColours,
B: FileColours,
{
fn colour_file(&self, file: &File) -> Option<Style> {
fn colour_file(&self, file: &File<'_>) -> Option<Style> {
self.0.colour_file(file)
.or_else(|| self.1.colour_file(file))
}

View File

@ -190,7 +190,7 @@ impl<'a> Render<'a> {
None
}
fn make_table(&mut self, options: &'a TableOptions, drender: &DetailsRender) -> (Table<'a>, Vec<DetailsRow>) {
fn make_table(&mut self, options: &'a TableOptions, drender: &DetailsRender<'_>) -> (Table<'a>, Vec<DetailsRow>) {
match (self.git, self.dir) {
(Some(g), Some(d)) => if ! g.has_anything_for(&d.path) { self.git = None },
(Some(g), None) => if ! self.files.iter().any(|f| g.has_anything_for(&f.path)) { self.git = None },
@ -209,7 +209,7 @@ impl<'a> Render<'a> {
(table, rows)
}
fn make_grid(&mut self, column_count: usize, options: &'a TableOptions, file_names: &[TextCell], rows: Vec<TableRow>, drender: &DetailsRender) -> grid::Grid {
fn make_grid(&mut self, column_count: usize, options: &'a TableOptions, file_names: &[TextCell], rows: Vec<TableRow>, drender: &DetailsRender<'_>) -> grid::Grid {
let mut tables = Vec::new();
for _ in 0 .. column_count {
tables.push(self.make_table(options, drender));
@ -294,7 +294,7 @@ fn divide_rounding_up(a: usize, b: usize) -> usize {
}
fn file_has_xattrs(file: &File) -> bool {
fn file_has_xattrs(file: &File<'_>) -> bool {
match file.path.attributes() {
Ok(attrs) => ! attrs.is_empty(),
Err(_) => false,

View File

@ -6,7 +6,7 @@ use crate::output::file_name::FileStyle;
pub trait FileIcon {
fn icon_file(&self, file: &File) -> Option<char>;
fn icon_file(&self, file: &File<'_>) -> Option<char>;
}
@ -28,7 +28,7 @@ impl Icons {
}
pub fn painted_icon(file: &File, style: &FileStyle) -> String {
pub fn painted_icon(file: &File<'_>, style: &FileStyle) -> String {
let file_icon = icon(file).to_string();
let painted = style.exts
.colour_file(file)
@ -53,7 +53,7 @@ pub fn painted_icon(file: &File, style: &FileStyle) -> String {
}
fn icon(file: &File) -> char {
fn icon(file: &File<'_>) -> char {
let extensions = Box::new(FileExtensions);
if file.points_to_directory() {

View File

@ -265,7 +265,7 @@ pub struct Environment {
}
impl Environment {
pub fn lock_users(&self) -> MutexGuard<UsersCache> {
pub fn lock_users(&self) -> MutexGuard<'_, UsersCache> {
self.users.lock().unwrap()
}
@ -347,7 +347,7 @@ impl<'a, 'f> Table<'a> {
Row { cells }
}
pub fn row_for_file(&self, file: &File, xattrs: bool) -> Row {
pub fn row_for_file(&self, file: &File<'_>, xattrs: bool) -> Row {
let cells = self.columns.iter()
.map(|c| self.display(file, *c, xattrs))
.collect();
@ -359,7 +359,7 @@ impl<'a, 'f> Table<'a> {
self.widths.add_widths(row)
}
fn permissions_plus(&self, file: &File, xattrs: bool) -> f::PermissionsPlus {
fn permissions_plus(&self, file: &File<'_>, xattrs: bool) -> f::PermissionsPlus {
f::PermissionsPlus {
file_type: file.type_char(),
permissions: file.permissions(),
@ -367,13 +367,13 @@ impl<'a, 'f> Table<'a> {
}
}
fn octal_permissions(&self, file: &File) -> f::OctalPermissions {
fn octal_permissions(&self, file: &File<'_>) -> f::OctalPermissions {
f::OctalPermissions {
permissions: file.permissions(),
}
}
fn display(&self, file: &File, column: Column, xattrs: bool) -> TextCell {
fn display(&self, file: &File<'_>, column: Column, xattrs: bool) -> TextCell {
match column {
Column::Permissions => {
self.permissions_plus(file, xattrs).render(self.colours)
@ -418,7 +418,7 @@ impl<'a, 'f> Table<'a> {
}
}
fn git_status(&self, file: &File) -> f::Git {
fn git_status(&self, file: &File<'_>) -> f::Git {
debug!("Getting Git status for file {:?}", file.path);
self.git

View File

@ -25,7 +25,7 @@ use unicode_width::UnicodeWidthStr;
///
/// Currently exa does not support *custom* styles, where the user enters a
/// format string in an environment variable or something. Just these four.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum TimeFormat {
/// The **default format** uses the users locale to print month names,

View File

@ -268,7 +268,7 @@ impl Colours {
/// Sets a value on this set of colours using one of the keys understood
/// by the `LS_COLORS` environment variable. Invalid keys set nothing, but
/// return false.
pub fn set_ls(&mut self, pair: &Pair) -> bool {
pub fn set_ls(&mut self, pair: &Pair<'_>) -> bool {
match pair.key {
"di" => self.filekinds.directory = pair.to_style(), // DIR
"ex" => self.filekinds.executable = pair.to_style(), // EXEC
@ -291,7 +291,7 @@ impl Colours {
/// by the `EXA_COLORS` environment variable. Invalid keys set nothing,
/// but return false. This doesnt take the `LS_COLORS` keys into account,
/// so `set_ls` should have been run first.
pub fn set_exa(&mut self, pair: &Pair) -> bool {
pub fn set_exa(&mut self, pair: &Pair<'_>) -> bool {
match pair.key {
"ur" => self.perms.user_read = pair.to_style(),
"uw" => self.perms.user_write = pair.to_style(),