diff --git a/src/fs/dir.rs b/src/fs/dir.rs
index 9b87ff5..a02c3e2 100644
--- a/src/fs/dir.rs
+++ b/src/fs/dir.rs
@@ -35,14 +35,14 @@ 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) -> IOResult {
info!("Reading directory {:?}", &path);
let contents = fs::read_dir(&path)?
.map(|result| result.map(|entry| entry.path()))
.collect::>()?;
- Ok(Dir { contents, path })
+ Ok(Self { contents, path })
}
/// Produce an iterator of IO results of trying to read all the files in
@@ -180,8 +180,8 @@ pub enum DotFilter {
}
impl Default for DotFilter {
- fn default() -> DotFilter {
- DotFilter::JustFiles
+ fn default() -> Self {
+ Self::JustFiles
}
}
@@ -190,18 +190,18 @@ impl DotFilter {
/// Whether this filter should show dotfiles in a listing.
fn shows_dotfiles(self) -> bool {
match self {
- DotFilter::JustFiles => false,
- DotFilter::Dotfiles => true,
- DotFilter::DotfilesAndDots => true,
+ Self::JustFiles => false,
+ Self::Dotfiles => true,
+ Self::DotfilesAndDots => true,
}
}
/// Whether this filter should add dot directories to a listing.
fn dots(self) -> DotsNext {
match self {
- DotFilter::JustFiles => DotsNext::Files,
- DotFilter::Dotfiles => DotsNext::Files,
- DotFilter::DotfilesAndDots => DotsNext::Dot,
+ Self::JustFiles => DotsNext::Files,
+ Self::Dotfiles => DotsNext::Files,
+ Self::DotfilesAndDots => DotsNext::Dot,
}
}
}
diff --git a/src/fs/dir_action.rs b/src/fs/dir_action.rs
index ce382ac..d72db88 100644
--- a/src/fs/dir_action.rs
+++ b/src/fs/dir_action.rs
@@ -41,7 +41,7 @@ impl DirAction {
/// Gets the recurse options, if this dir action has any.
pub fn recurse_options(&self) -> Option {
match *self {
- DirAction::Recurse(o) => Some(o),
+ Self::Recurse(o) => Some(o),
_ => None,
}
}
@@ -49,8 +49,8 @@ impl DirAction {
/// Whether to treat directories as regular files or not.
pub fn treat_dirs_as_files(&self) -> bool {
match *self {
- DirAction::AsFile => true,
- DirAction::Recurse(o) => o.tree,
+ Self::AsFile => true,
+ Self::Recurse(o) => o.tree,
_ => false,
}
}
diff --git a/src/fs/feature/git.rs b/src/fs/feature/git.rs
index 7cf68a8..05b15ef 100644
--- a/src/fs/feature/git.rs
+++ b/src/fs/feature/git.rs
@@ -38,7 +38,7 @@ use std::iter::FromIterator;
impl FromIterator for GitCache {
fn from_iter>(iter: I) -> Self {
let iter = iter.into_iter();
- let mut git = GitCache {
+ let mut git = Self {
repos: Vec::with_capacity(iter.size_hint().0),
misses: Vec::new(),
};
@@ -152,7 +152,7 @@ impl GitRepo {
/// Searches for a Git repository at any point above the given path.
/// Returns the original buffer if none is found.
- fn discover(path: PathBuf) -> Result {
+ fn discover(path: PathBuf) -> Result {
info!("Searching for Git repository above {:?}", path);
let repo = match git2::Repository::discover(&path) {
Ok(r) => r,
@@ -165,7 +165,7 @@ impl GitRepo {
match repo.workdir().map(|wd| wd.to_path_buf()) {
Some(workdir) => {
let contents = Mutex::new(GitContents::Before { repo });
- Ok(GitRepo { contents, workdir, original_path: path, extra_paths: Vec::new() })
+ Ok(Self { contents, workdir, original_path: path, extra_paths: Vec::new() })
},
None => {
warn!("Repository has no workdir?");
@@ -181,7 +181,7 @@ impl GitContents {
/// (consuming the value) if it has. This is needed because the entire
/// enum variant gets replaced when a repo is queried (see above).
fn inner_repo(self) -> git2::Repository {
- if let GitContents::Before { repo } = self {
+ if let Self::Before { repo } = self {
repo
}
else {
diff --git a/src/fs/feature/xattr.rs b/src/fs/feature/xattr.rs
index f39e3c8..d028e17 100644
--- a/src/fs/feature/xattr.rs
+++ b/src/fs/feature/xattr.rs
@@ -126,13 +126,13 @@ mod lister {
}
impl Lister {
- pub fn new(do_follow: FollowSymlinks) -> Lister {
+ pub fn new(do_follow: FollowSymlinks) -> Self {
let c_flags: c_int = match do_follow {
FollowSymlinks::Yes => 0x0001,
FollowSymlinks::No => 0x0000,
};
- Lister { c_flags }
+ Self { c_flags }
}
pub fn translate_attribute_name(&self, input: &[u8]) -> String {
diff --git a/src/fs/fields.rs b/src/fs/fields.rs
index f3d6735..28c022d 100644
--- a/src/fs/fields.rs
+++ b/src/fs/fields.rs
@@ -50,7 +50,7 @@ pub enum Type {
impl Type {
pub fn is_regular_file(&self) -> bool {
- matches!(*self, Type::File)
+ matches!(*self, Self::File)
}
}
@@ -220,7 +220,7 @@ use std::default::Default;
impl Default for Git {
/// Create a Git status for a file with nothing done to it.
- fn default() -> Git {
- Git { staged: GitStatus::NotModified, unstaged: GitStatus::NotModified }
+ fn default() -> Self {
+ Self { staged: GitStatus::NotModified, unstaged: GitStatus::NotModified }
}
}
diff --git a/src/fs/filter.rs b/src/fs/filter.rs
index c7e2169..937caff 100644
--- a/src/fs/filter.rs
+++ b/src/fs/filter.rs
@@ -240,41 +240,41 @@ impl SortField {
use self::SortCase::{ABCabc, AaBbCc};
match self {
- SortField::Unsorted => Ordering::Equal,
+ Self::Unsorted => Ordering::Equal,
- SortField::Name(ABCabc) => natord::compare(&a.name, &b.name),
- SortField::Name(AaBbCc) => natord::compare_ignore_case(&a.name, &b.name),
+ Self::Name(ABCabc) => natord::compare(&a.name, &b.name),
+ Self::Name(AaBbCc) => natord::compare_ignore_case(&a.name, &b.name),
- SortField::Size => a.metadata.len().cmp(&b.metadata.len()),
- SortField::FileInode => a.metadata.ino().cmp(&b.metadata.ino()),
- SortField::ModifiedDate => a.modified_time().cmp(&b.modified_time()),
- SortField::AccessedDate => a.accessed_time().cmp(&b.accessed_time()),
- SortField::ChangedDate => a.changed_time().cmp(&b.changed_time()),
- SortField::CreatedDate => a.created_time().cmp(&b.created_time()),
- SortField::ModifiedAge => b.modified_time().cmp(&a.modified_time()), // flip b and a
+ Self::Size => a.metadata.len().cmp(&b.metadata.len()),
+ Self::FileInode => a.metadata.ino().cmp(&b.metadata.ino()),
+ Self::ModifiedDate => a.modified_time().cmp(&b.modified_time()),
+ Self::AccessedDate => a.accessed_time().cmp(&b.accessed_time()),
+ Self::ChangedDate => a.changed_time().cmp(&b.changed_time()),
+ Self::CreatedDate => a.created_time().cmp(&b.created_time()),
+ Self::ModifiedAge => b.modified_time().cmp(&a.modified_time()), // flip b and a
- SortField::FileType => match a.type_char().cmp(&b.type_char()) { // todo: this recomputes
+ Self::FileType => match a.type_char().cmp(&b.type_char()) { // todo: this recomputes
Ordering::Equal => natord::compare(&*a.name, &*b.name),
order => order,
},
- SortField::Extension(ABCabc) => match a.ext.cmp(&b.ext) {
+ Self::Extension(ABCabc) => match a.ext.cmp(&b.ext) {
Ordering::Equal => natord::compare(&*a.name, &*b.name),
order => order,
},
- SortField::Extension(AaBbCc) => match a.ext.cmp(&b.ext) {
+ Self::Extension(AaBbCc) => match a.ext.cmp(&b.ext) {
Ordering::Equal => natord::compare_ignore_case(&*a.name, &*b.name),
order => order,
},
- SortField::NameMixHidden(ABCabc) => natord::compare(
- SortField::strip_dot(&a.name),
- SortField::strip_dot(&b.name)
+ Self::NameMixHidden(ABCabc) => natord::compare(
+ Self::strip_dot(&a.name),
+ Self::strip_dot(&b.name)
),
- SortField::NameMixHidden(AaBbCc) => natord::compare_ignore_case(
- SortField::strip_dot(&a.name),
- SortField::strip_dot(&b.name)
+ Self::NameMixHidden(AaBbCc) => natord::compare_ignore_case(
+ Self::strip_dot(&a.name),
+ Self::strip_dot(&b.name)
)
}
}
@@ -299,7 +299,7 @@ pub struct IgnorePatterns {
impl FromIterator for IgnorePatterns {
fn from_iter>(iter: I) -> Self {
- IgnorePatterns { patterns: iter.into_iter().collect() }
+ Self { patterns: iter.into_iter().collect() }
}
}
@@ -328,12 +328,12 @@ impl IgnorePatterns {
}
}
- (IgnorePatterns { patterns }, errors)
+ (Self { patterns }, errors)
}
/// Create a new empty set of patterns that matches nothing.
- pub fn empty() -> IgnorePatterns {
- IgnorePatterns { patterns: Vec::new() }
+ pub fn empty() -> Self {
+ Self { patterns: Vec::new() }
}
/// Test whether the given file should be hidden from the results.
diff --git a/src/options/dir_action.rs b/src/options/dir_action.rs
index 119fc95..7316ddf 100644
--- a/src/options/dir_action.rs
+++ b/src/options/dir_action.rs
@@ -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 {
+ pub fn deduce(matches: &MatchedFlags) -> Result {
let recurse = matches.has(&flags::RECURSE)?;
let as_file = matches.has(&flags::LIST_DIRS)?;
let tree = matches.has(&flags::TREE)?;
@@ -31,16 +31,16 @@ impl DirAction {
}
if tree {
- Ok(DirAction::Recurse(RecurseOptions::deduce(matches, true)?))
+ Ok(Self::Recurse(RecurseOptions::deduce(matches, true)?))
}
else if recurse {
- Ok(DirAction::Recurse(RecurseOptions::deduce(matches, false)?))
+ Ok(Self::Recurse(RecurseOptions::deduce(matches, false)?))
}
else if as_file {
- Ok(DirAction::AsFile)
+ Ok(Self::AsFile)
}
else {
- Ok(DirAction::List)
+ Ok(Self::List)
}
}
}
@@ -52,7 +52,7 @@ impl RecurseOptions {
/// flag’s 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 isn’t.
- pub fn deduce(matches: &MatchedFlags, tree: bool) -> Result {
+ pub fn deduce(matches: &MatchedFlags, tree: bool) -> Result {
let max_depth = if let Some(level) = matches.get(&flags::LEVEL)? {
match level.to_string_lossy().parse() {
Ok(l) => Some(l),
@@ -63,7 +63,7 @@ impl RecurseOptions {
None
};
- Ok(RecurseOptions { tree, max_depth })
+ Ok(Self { tree, max_depth })
}
}
diff --git a/src/options/filter.rs b/src/options/filter.rs
index 48607fe..9005b66 100644
--- a/src/options/filter.rs
+++ b/src/options/filter.rs
@@ -10,8 +10,8 @@ use crate::options::parser::MatchedFlags;
impl FileFilter {
/// Determines which of all the file filter options to use.
- pub fn deduce(matches: &MatchedFlags) -> Result {
- Ok(FileFilter {
+ pub fn deduce(matches: &MatchedFlags) -> Result {
+ Ok(Self {
list_dirs_first: matches.has(&flags::DIRS_FIRST)?,
reverse: matches.has(&flags::REVERSE)?,
only_dirs: matches.has(&flags::ONLY_DIRS)?,
@@ -29,10 +29,10 @@ impl SortField {
/// This argument’s value can be one of several flags, listed above.
/// Returns the default sort field if none is given, or `Err` if the
/// value doesn’t correspond to a sort field we know about.
- fn deduce(matches: &MatchedFlags) -> Result {
+ fn deduce(matches: &MatchedFlags) -> Result {
let word = match matches.get(&flags::SORT)? {
Some(w) => w,
- None => return Ok(SortField::default()),
+ None => return Ok(Self::default()),
};
// Get String because we can’t match an OsStr
@@ -42,28 +42,28 @@ impl SortField {
};
let field = match word {
- "name" | "filename" => SortField::Name(SortCase::AaBbCc),
- "Name" | "Filename" => SortField::Name(SortCase::ABCabc),
- ".name" | ".filename" => SortField::NameMixHidden(SortCase::AaBbCc),
- ".Name" | ".Filename" => SortField::NameMixHidden(SortCase::ABCabc),
- "size" | "filesize" => SortField::Size,
- "ext" | "extension" => SortField::Extension(SortCase::AaBbCc),
- "Ext" | "Extension" => SortField::Extension(SortCase::ABCabc),
+ "name" | "filename" => Self::Name(SortCase::AaBbCc),
+ "Name" | "Filename" => Self::Name(SortCase::ABCabc),
+ ".name" | ".filename" => Self::NameMixHidden(SortCase::AaBbCc),
+ ".Name" | ".Filename" => Self::NameMixHidden(SortCase::ABCabc),
+ "size" | "filesize" => Self::Size,
+ "ext" | "extension" => Self::Extension(SortCase::AaBbCc),
+ "Ext" | "Extension" => Self::Extension(SortCase::ABCabc),
// “new” sorts oldest at the top and newest at the bottom; “old”
// sorts newest at the top and oldest at the bottom. I think this
// is the right way round to do this: “size” puts the smallest at
// the top and the largest at the bottom, doesn’t it?
- "date" | "time" | "mod" | "modified" | "new" | "newest" => SortField::ModifiedDate,
+ "date" | "time" | "mod" | "modified" | "new" | "newest" => Self::ModifiedDate,
// Similarly, “age” means that files with the least age (the
// newest files) get sorted at the top, and files with the most
// age (the oldest) at the bottom.
- "age" | "old" | "oldest" => SortField::ModifiedAge,
- "ch" | "changed" => SortField::ChangedDate,
- "acc" | "accessed" => SortField::AccessedDate,
- "cr" | "created" => SortField::CreatedDate,
- "inode" => SortField::FileInode,
- "type" => SortField::FileType,
- "none" => SortField::Unsorted,
+ "age" | "old" | "oldest" => Self::ModifiedAge,
+ "ch" | "changed" => Self::ChangedDate,
+ "acc" | "accessed" => Self::AccessedDate,
+ "cr" | "created" => Self::CreatedDate,
+ "inode" => Self::FileInode,
+ "type" => Self::FileType,
+ "none" => Self::Unsorted,
_ => return Err(Misfire::BadArgument(&flags::SORT, word.into()))
};
@@ -105,8 +105,8 @@ impl SortField {
// You can get the old behaviour back by sorting with `--sort=Name`.
impl Default for SortField {
- fn default() -> SortField {
- SortField::Name(SortCase::AaBbCc)
+ fn default() -> Self {
+ Self::Name(SortCase::AaBbCc)
}
}
@@ -119,14 +119,14 @@ impl DotFilter {
/// It also checks for the `--tree` option in strict mode, because of a
/// special case where `--tree --all --all` won’t work: listing the
/// parent directory in tree mode would loop onto itself!
- pub fn deduce(matches: &MatchedFlags) -> Result {
+ pub fn deduce(matches: &MatchedFlags) -> Result {
let count = matches.count(&flags::ALL);
if count == 0 {
- Ok(DotFilter::JustFiles)
+ Ok(Self::JustFiles)
}
else if count == 1 {
- Ok(DotFilter::Dotfiles)
+ Ok(Self::Dotfiles)
}
else if matches.count(&flags::TREE) > 0 {
Err(Misfire::TreeAllAll)
@@ -135,7 +135,7 @@ impl DotFilter {
Err(Misfire::Conflict(&flags::ALL, &flags::ALL))
}
else {
- Ok(DotFilter::DotfilesAndDots)
+ Ok(Self::DotfilesAndDots)
}
}
}
@@ -146,18 +146,18 @@ impl IgnorePatterns {
/// Determines the set of glob patterns to use based on the
/// `--ignore-glob` argument’s value. This is a list of strings
/// separated by pipe (`|`) characters, given in any order.
- pub fn deduce(matches: &MatchedFlags) -> Result {
+ pub fn deduce(matches: &MatchedFlags) -> Result {
// If there are no inputs, we return a set of patterns that doesn’t
// match anything, rather than, say, `None`.
let inputs = match matches.get(&flags::IGNORE_GLOB)? {
- None => return Ok(IgnorePatterns::empty()),
+ None => return Ok(Self::empty()),
Some(is) => is,
};
// Awkwardly, though, a glob pattern can be invalid, and we need to
// deal with invalid patterns somehow.
- let (patterns, mut errors) = IgnorePatterns::parse_from_iter(inputs.to_string_lossy().split('|'));
+ let (patterns, mut errors) = Self::parse_from_iter(inputs.to_string_lossy().split('|'));
// It can actually return more than one glob error,
// but we only use one. (TODO)
@@ -171,8 +171,8 @@ impl IgnorePatterns {
impl GitIgnore {
pub fn deduce(matches: &MatchedFlags) -> Result {
- Ok(if matches.has(&flags::GIT_IGNORE)? { GitIgnore::CheckAndIgnore }
- else { GitIgnore::Off })
+ Ok(if matches.has(&flags::GIT_IGNORE)? { Self::CheckAndIgnore }
+ else { Self::Off })
}
}
diff --git a/src/options/help.rs b/src/options/help.rs
index c934fea..d4d6bc5 100644
--- a/src/options/help.rs
+++ b/src/options/help.rs
@@ -86,12 +86,12 @@ impl HelpString {
/// We don’t do any strict-mode error checking here: it’s 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) -> Result<(), HelpString> {
+ pub fn deduce(matches: &MatchedFlags) -> Result<(), Self> {
if matches.count(&flags::HELP) > 0 {
let only_long = matches.count(&flags::LONG) > 0;
let git = cfg!(feature="git");
let xattrs = xattr::ENABLED;
- Err(HelpString { only_long, git, xattrs })
+ Err(Self { only_long, git, xattrs })
}
else {
Ok(()) // no help needs to be shown
diff --git a/src/options/misfire.rs b/src/options/misfire.rs
index f0bf9f4..0f86a54 100644
--- a/src/options/misfire.rs
+++ b/src/options/misfire.rs
@@ -56,16 +56,16 @@ impl Misfire {
/// The OS return code this misfire should signify.
pub fn is_error(&self) -> bool {
match *self {
- Misfire::Help(_) => false,
- Misfire::Version(_) => false,
+ Self::Help(_) => false,
+ Self::Version(_) => false,
_ => true,
}
}
}
impl From for Misfire {
- fn from(error: glob::PatternError) -> Misfire {
- Misfire::FailedGlobPattern(error.to_string())
+ fn from(error: glob::PatternError) -> Self {
+ Self::FailedGlobPattern(error.to_string())
}
}
@@ -120,9 +120,9 @@ impl Misfire {
pub fn suggestion(&self) -> Option<&'static str> {
// ‘ls -lt’ and ‘ls -ltr’ are common combinations
match *self {
- Misfire::BadArgument(ref time, ref r) if *time == &flags::TIME && r == "r" =>
+ Self::BadArgument(ref time, ref r) if *time == &flags::TIME && r == "r" =>
Some("To sort oldest files last, try \"--sort oldest\", or just \"-sold\""),
- Misfire::InvalidOptions(ParseError::NeedsValue { ref flag, .. }) if *flag == Flag::Short(b't') =>
+ Self::InvalidOptions(ParseError::NeedsValue { ref flag, .. }) if *flag == Flag::Short(b't') =>
Some("To sort newest files last, try \"--sort newest\", or just \"-snew\""),
_ => None
}
diff --git a/src/options/mod.rs b/src/options/mod.rs
index 620a5a9..dd9896c 100644
--- a/src/options/mod.rs
+++ b/src/options/mod.rs
@@ -119,7 +119,7 @@ impl Options {
/// struct and a list of free filenames, using the environment variables
/// for extra options.
#[allow(unused_results)]
- pub fn parse<'args, I, V>(args: I, vars: &V) -> Result<(Options, Vec<&'args OsStr>), Misfire>
+ pub fn parse<'args, I, V>(args: I, vars: &V) -> Result<(Self, Vec<&'args OsStr>), Misfire>
where I: IntoIterator- ,
V: Vars {
use crate::options::parser::{Matches, Strictness};
@@ -138,7 +138,7 @@ impl Options {
HelpString::deduce(&flags).map_err(Misfire::Help)?;
VersionString::deduce(&flags).map_err(Misfire::Version)?;
- let options = Options::deduce(&flags, vars)?;
+ let options = Self::deduce(&flags, vars)?;
Ok((options, frees))
}
@@ -159,12 +159,12 @@ impl Options {
/// Determines the complete set of options based on the given command-line
/// arguments, after they’ve been parsed.
- fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
+ fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
let dir_action = DirAction::deduce(matches)?;
let filter = FileFilter::deduce(matches)?;
let view = View::deduce(matches, vars)?;
- Ok(Options { dir_action, view, filter })
+ Ok(Self { dir_action, view, filter })
}
}
diff --git a/src/options/parser.rs b/src/options/parser.rs
index 909538c..ef4072b 100644
--- a/src/options/parser.rs
+++ b/src/options/parser.rs
@@ -61,8 +61,8 @@ pub enum Flag {
impl Flag {
pub fn matches(&self, arg: &Arg) -> bool {
match *self {
- Flag::Short(short) => arg.short == Some(short),
- Flag::Long(long) => arg.long == long,
+ Self::Short(short) => arg.short == Some(short),
+ Self::Long(long) => arg.long == long,
}
}
}
@@ -70,8 +70,8 @@ impl Flag {
impl fmt::Display for Flag {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
- Flag::Short(short) => write!(f, "-{}", short as char),
- Flag::Long(long) => write!(f, "--{}", long),
+ Self::Short(short) => write!(f, "-{}", short as char),
+ Self::Long(long) => write!(f, "--{}", long),
}
}
}
diff --git a/src/options/style.rs b/src/options/style.rs
index 133e0df..3f5b3fe 100644
--- a/src/options/style.rs
+++ b/src/options/style.rs
@@ -28,8 +28,8 @@ enum TerminalColours {
}
impl Default for TerminalColours {
- fn default() -> TerminalColours {
- TerminalColours::Automatic
+ fn default() -> Self {
+ Self::Automatic
}
}
@@ -37,21 +37,21 @@ impl Default for TerminalColours {
impl TerminalColours {
/// Determine which terminal colour conditions to use.
- fn deduce(matches: &MatchedFlags) -> Result {
+ fn deduce(matches: &MatchedFlags) -> Result {
let word = match matches.get_where(|f| f.matches(&flags::COLOR) || f.matches(&flags::COLOUR))? {
Some(w) => w,
- None => return Ok(TerminalColours::default()),
+ None => return Ok(Self::default()),
};
if word == "always" {
- Ok(TerminalColours::Always)
+ Ok(Self::Always)
}
else if word == "auto" || word == "automatic" {
- Ok(TerminalColours::Automatic)
+ Ok(Self::Automatic)
}
else if word == "never" {
- Ok(TerminalColours::Never)
+ Ok(Self::Never)
}
else {
Err(Misfire::BadArgument(&flags::COLOR, word.into()))
@@ -90,7 +90,7 @@ impl Styles {
// custom colours at all
let tc = TerminalColours::deduce(matches)?;
if tc == Never || (tc == Automatic && widther().is_none()) {
- return Ok(Styles {
+ return Ok(Self {
colours: Colours::plain(),
style: FileStyle { classify, exts: Box::new(NoFileColours) },
});
@@ -111,7 +111,7 @@ impl Styles {
};
let style = FileStyle { classify, exts };
- Ok(Styles { colours, style })
+ Ok(Self { colours, style })
}
}
@@ -197,11 +197,11 @@ impl ExtensionMappings {
impl Classify {
- fn deduce(matches: &MatchedFlags) -> Result {
+ fn deduce(matches: &MatchedFlags) -> Result {
let flagged = matches.has(&flags::CLASSIFY)?;
- Ok(if flagged { Classify::AddFileIndicators }
- else { Classify::JustFilenames })
+ Ok(if flagged { Self::AddFileIndicators }
+ else { Self::JustFilenames })
}
}
diff --git a/src/options/version.rs b/src/options/version.rs
index 0b26c07..ae151b4 100644
--- a/src/options/version.rs
+++ b/src/options/version.rs
@@ -19,9 +19,9 @@ impl VersionString {
/// ‘deduce’ functions, returning Err if help needs to be shown.
///
/// Like --help, this doesn’t bother checking for errors.
- pub fn deduce(matches: &MatchedFlags) -> Result<(), VersionString> {
+ pub fn deduce(matches: &MatchedFlags) -> Result<(), Self> {
if matches.count(&flags::VERSION) > 0 {
- Err(VersionString)
+ Err(Self)
}
else {
Ok(()) // no version needs to be shown
diff --git a/src/options/view.rs b/src/options/view.rs
index cb17cde..72a2e55 100644
--- a/src/options/view.rs
+++ b/src/options/view.rs
@@ -13,12 +13,12 @@ use crate::fs::feature::xattr;
impl View {
/// Determine which view to use and all of that view’s arguments.
- pub fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
+ pub fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
use crate::options::style::Styles;
let mode = Mode::deduce(matches, vars)?;
let Styles { colours, style } = Styles::deduce(matches, vars, || *TERM_WIDTH)?;
- Ok(View { mode, colours, style })
+ Ok(Self { mode, colours, style })
}
}
@@ -26,7 +26,7 @@ impl View {
impl Mode {
/// Determine the mode from the command-line arguments.
- pub fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
+ pub fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
use crate::options::misfire::Misfire::*;
let long = || {
@@ -54,7 +54,7 @@ impl Mode {
}
else {
let lines = lines::Options { icons: matches.has(&flags::ICONS)? };
- Ok(Mode::Lines(lines))
+ Ok(Self::Lines(lines))
}
}
else if matches.has(&flags::TREE)? {
@@ -65,7 +65,7 @@ impl Mode {
icons: matches.has(&flags::ICONS)?,
};
- Ok(Mode::Details(details))
+ Ok(Self::Details(details))
}
else {
let grid = grid::Options {
@@ -74,7 +74,7 @@ impl Mode {
icons: matches.has(&flags::ICONS)?,
};
- Ok(Mode::Grid(grid))
+ Ok(Self::Grid(grid))
}
}
@@ -89,14 +89,14 @@ impl Mode {
icons: matches.has(&flags::ICONS)?,
};
- Ok(Mode::Details(details))
+ Ok(Self::Details(details))
}
else if matches.has(&flags::LONG)? {
let details = long()?;
- Ok(Mode::Details(details))
+ Ok(Self::Details(details))
} else {
let lines = lines::Options { icons: matches.has(&flags::ICONS)?, };
- Ok(Mode::Lines(lines))
+ Ok(Self::Lines(lines))
}
};
@@ -104,16 +104,16 @@ impl Mode {
let details = long()?;
if matches.has(&flags::GRID)? {
let other_options_mode = other_options_scan()?;
- if let Mode::Grid(grid) = other_options_mode {
+ if let Self::Grid(grid) = other_options_mode {
let row_threshold = RowThreshold::deduce(vars)?;
- return Ok(Mode::GridDetails(grid_details::Options { grid, details, row_threshold }));
+ return Ok(Self::GridDetails(grid_details::Options { grid, details, row_threshold }));
}
else {
return Ok(other_options_mode);
}
}
else {
- return Ok(Mode::Details(details));
+ return Ok(Self::Details(details));
}
}
@@ -161,28 +161,28 @@ impl TerminalWidth {
/// Determine a requested terminal width from the command-line arguments.
///
/// Returns an error if a requested width doesn’t parse to an integer.
- fn deduce(vars: &V) -> Result {
+ fn deduce(vars: &V) -> Result {
use crate::options::vars;
if let Some(columns) = vars.get(vars::COLUMNS).and_then(|s| s.into_string().ok()) {
match columns.parse() {
- Ok(width) => Ok(TerminalWidth::Set(width)),
+ Ok(width) => Ok(Self::Set(width)),
Err(e) => Err(Misfire::FailedParse(e)),
}
}
else if let Some(width) = *TERM_WIDTH {
- Ok(TerminalWidth::Terminal(width))
+ Ok(Self::Terminal(width))
}
else {
- Ok(TerminalWidth::Unset)
+ Ok(Self::Unset)
}
}
fn width(&self) -> Option {
match *self {
- TerminalWidth::Set(width) |
- TerminalWidth::Terminal(width) => Some(width),
- TerminalWidth::Unset => None,
+ Self::Set(width) |
+ Self::Terminal(width) => Some(width),
+ Self::Unset => None,
}
}
}
@@ -192,17 +192,17 @@ impl RowThreshold {
/// Determine whether to use a row threshold based on the given
/// environment variables.
- fn deduce(vars: &V) -> Result {
+ fn deduce(vars: &V) -> Result {
use crate::options::vars;
if let Some(columns) = vars.get(vars::EXA_GRID_ROWS).and_then(|s| s.into_string().ok()) {
match columns.parse() {
- Ok(rows) => Ok(RowThreshold::MinimumRows(rows)),
+ Ok(rows) => Ok(Self::MinimumRows(rows)),
Err(e) => Err(Misfire::FailedParse(e)),
}
}
else {
- Ok(RowThreshold::AlwaysGrid)
+ Ok(Self::AlwaysGrid)
}
}
}
@@ -214,7 +214,7 @@ impl TableOptions {
let time_format = TimeFormat::deduce(matches, vars)?;
let size_format = SizeFormat::deduce(matches)?;
let columns = Columns::deduce(matches)?;
- Ok(TableOptions { env, time_format, size_format, columns })
+ Ok(Self { env, time_format, size_format, columns })
}
}
@@ -234,7 +234,7 @@ impl Columns {
let filesize = !matches.has(&flags::NO_FILESIZE)?;
let user = !matches.has(&flags::NO_USER)?;
- Ok(Columns { time_types, git, octal, blocks, group, inode, links, permissions, filesize, user })
+ Ok(Self { time_types, git, octal, blocks, group, inode, links, permissions, filesize, user })
}
}
@@ -249,13 +249,13 @@ 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 {
+ fn deduce(matches: &MatchedFlags) -> Result {
let flag = matches.has_where(|f| f.matches(&flags::BINARY) || f.matches(&flags::BYTES))?;
Ok(match flag {
- Some(f) if f.matches(&flags::BINARY) => SizeFormat::BinaryBytes,
- Some(f) if f.matches(&flags::BYTES) => SizeFormat::JustBytes,
- _ => SizeFormat::DecimalBytes,
+ Some(f) if f.matches(&flags::BINARY) => Self::BinaryBytes,
+ Some(f) if f.matches(&flags::BYTES) => Self::JustBytes,
+ _ => Self::DecimalBytes,
})
}
}
@@ -264,7 +264,7 @@ impl SizeFormat {
impl TimeFormat {
/// Determine how time should be formatted in timestamp columns.
- fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
+ fn deduce(matches: &MatchedFlags, vars: &V) -> Result {
pub use crate::output::time::{DefaultFormat, ISOFormat};
let word = match matches.get(&flags::TIME_STYLE)? {
@@ -273,22 +273,22 @@ impl TimeFormat {
use crate::options::vars;
match vars.get(vars::TIME_STYLE) {
Some(ref t) if !t.is_empty() => t.clone(),
- _ => return Ok(TimeFormat::DefaultFormat(DefaultFormat::load()))
+ _ => return Ok(Self::DefaultFormat(DefaultFormat::load()))
}
},
};
if &word == "default" {
- Ok(TimeFormat::DefaultFormat(DefaultFormat::load()))
+ Ok(Self::DefaultFormat(DefaultFormat::load()))
}
else if &word == "iso" {
- Ok(TimeFormat::ISOFormat(ISOFormat::load()))
+ Ok(Self::ISOFormat(ISOFormat::load()))
}
else if &word == "long-iso" {
- Ok(TimeFormat::LongISO)
+ Ok(Self::LongISO)
}
else if &word == "full-iso" {
- Ok(TimeFormat::FullISO)
+ Ok(Self::FullISO)
}
else {
Err(Misfire::BadArgument(&flags::TIME_STYLE, word))
@@ -309,7 +309,7 @@ impl TimeTypes {
/// It’s 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 {
+ fn deduce(matches: &MatchedFlags) -> Result {
let possible_word = matches.get(&flags::TIME)?;
let modified = matches.has(&flags::MODIFIED)?;
let changed = matches.has(&flags::CHANGED)?;
@@ -319,7 +319,7 @@ impl TimeTypes {
let no_time = matches.has(&flags::NO_TIME)?;
let time_types = if no_time {
- TimeTypes { modified: false, changed: false, accessed: false, created: false }
+ Self { modified: false, changed: false, accessed: false, created: false }
} else if let Some(word) = possible_word {
if modified {
return Err(Misfire::Useless(&flags::MODIFIED, true, &flags::TIME));
@@ -334,26 +334,26 @@ impl TimeTypes {
return Err(Misfire::Useless(&flags::CREATED, true, &flags::TIME));
}
else if word == "mod" || word == "modified" {
- TimeTypes { modified: true, changed: false, accessed: false, created: false }
+ Self { modified: true, changed: false, accessed: false, created: false }
}
else if word == "ch" || word == "changed" {
- TimeTypes { modified: false, changed: true, accessed: false, created: false }
+ Self { modified: false, changed: true, accessed: false, created: false }
}
else if word == "acc" || word == "accessed" {
- TimeTypes { modified: false, changed: false, accessed: true, created: false }
+ Self { modified: false, changed: false, accessed: true, created: false }
}
else if word == "cr" || word == "created" {
- TimeTypes { modified: false, changed: false, accessed: false, created: true }
+ Self { modified: false, changed: false, accessed: false, created: true }
}
else {
return Err(Misfire::BadArgument(&flags::TIME, word.into()));
}
}
else if modified || changed || accessed || created {
- TimeTypes { modified, changed, accessed, created }
+ Self { modified, changed, accessed, created }
}
else {
- TimeTypes::default()
+ Self::default()
};
Ok(time_types)
diff --git a/src/output/cell.rs b/src/output/cell.rs
index 3833606..25996e0 100644
--- a/src/output/cell.rs
+++ b/src/output/cell.rs
@@ -42,7 +42,7 @@ impl TextCell {
pub fn paint(style: Style, text: String) -> Self {
let width = DisplayWidth::from(&*text);
- TextCell {
+ Self {
contents: vec![ style.paint(text) ].into(),
width,
}
@@ -54,7 +54,7 @@ impl TextCell {
pub fn paint_str(style: Style, text: &'static str) -> Self {
let width = DisplayWidth::from(text);
- TextCell {
+ Self {
contents: vec![ style.paint(text) ].into(),
width,
}
@@ -67,7 +67,7 @@ impl TextCell {
/// This is used in place of empty table cells, as it is easier to read
/// tabular data when there is *something* in each cell.
pub fn blank(style: Style) -> Self {
- TextCell {
+ Self {
contents: vec![ style.paint("-") ].into(),
width: DisplayWidth::from(1),
}
@@ -92,7 +92,7 @@ impl TextCell {
}
/// Adds all the contents of another `TextCell` to the end of this cell.
- pub fn append(&mut self, other: TextCell) {
+ pub fn append(&mut self, other: Self) {
(*self.width) += *other.width;
self.contents.0.extend(other.contents.0);
}
@@ -136,8 +136,8 @@ impl TextCell {
pub struct TextCellContents(Vec>);
impl From>> for TextCellContents {
- fn from(strings: Vec>) -> TextCellContents {
- TextCellContents(strings)
+ fn from(strings: Vec>) -> Self {
+ Self(strings)
}
}
@@ -197,14 +197,14 @@ impl TextCellContents {
pub struct DisplayWidth(usize);
impl<'a> From<&'a str> for DisplayWidth {
- fn from(input: &'a str) -> DisplayWidth {
- DisplayWidth(UnicodeWidthStr::width(input))
+ fn from(input: &'a str) -> Self {
+ Self(UnicodeWidthStr::width(input))
}
}
impl From for DisplayWidth {
- fn from(width: usize) -> DisplayWidth {
- DisplayWidth(width)
+ fn from(width: usize) -> Self {
+ Self(width)
}
}
@@ -223,24 +223,24 @@ impl DerefMut for DisplayWidth {
}
impl Add for DisplayWidth {
- type Output = DisplayWidth;
+ type Output = Self;
- fn add(self, rhs: DisplayWidth) -> Self::Output {
- DisplayWidth(self.0 + rhs.0)
+ fn add(self, rhs: Self) -> Self::Output {
+ Self(self.0 + rhs.0)
}
}
impl Add for DisplayWidth {
- type Output = DisplayWidth;
+ type Output = Self;
fn add(self, rhs: usize) -> Self::Output {
- DisplayWidth(self.0 + rhs)
+ Self(self.0 + rhs)
}
}
impl Sum for DisplayWidth {
fn sum(iter: I) -> Self where I: Iterator
- {
- iter.fold(DisplayWidth(0), Add::add)
+ iter.fold(Self(0), Add::add)
}
}
diff --git a/src/output/file_name.rs b/src/output/file_name.rs
index e21b299..526fedd 100644
--- a/src/output/file_name.rs
+++ b/src/output/file_name.rs
@@ -65,8 +65,8 @@ pub enum Classify {
}
impl Default for Classify {
- fn default() -> Classify {
- Classify::JustFilenames
+ fn default() -> Self {
+ Self::JustFilenames
}
}
diff --git a/src/output/icons.rs b/src/output/icons.rs
index ea2e297..7af0a9f 100644
--- a/src/output/icons.rs
+++ b/src/output/icons.rs
@@ -17,9 +17,9 @@ pub enum Icons {
impl Icons {
pub fn value(&self) -> char {
match *self {
- Icons::Audio => '\u{f001}',
- Icons::Image => '\u{f1c5}',
- Icons::Video => '\u{f03d}',
+ Self::Audio => '\u{f001}',
+ Self::Image => '\u{f1c5}',
+ Self::Video => '\u{f03d}',
}
}
}
diff --git a/src/output/render/blocks.rs b/src/output/render/blocks.rs
index 8df019f..97e2e8d 100644
--- a/src/output/render/blocks.rs
+++ b/src/output/render/blocks.rs
@@ -7,8 +7,8 @@ use crate::fs::fields as f;
impl f::Blocks {
pub fn render(&self, colours: &C) -> TextCell {
match *self {
- f::Blocks::Some(ref blk) => TextCell::paint(colours.block_count(), blk.to_string()),
- f::Blocks::None => TextCell::blank(colours.no_blocks()),
+ Self::Some(ref blk) => TextCell::paint(colours.block_count(), blk.to_string()),
+ Self::None => TextCell::blank(colours.no_blocks()),
}
}
}
diff --git a/src/output/render/filetype.rs b/src/output/render/filetype.rs
index bf46f26..5ba60fa 100644
--- a/src/output/render/filetype.rs
+++ b/src/output/render/filetype.rs
@@ -6,14 +6,14 @@ use crate::fs::fields as f;
impl f::Type {
pub fn render(&self, colours: &C) -> ANSIString<'static> {
match *self {
- f::Type::File => colours.normal().paint("."),
- f::Type::Directory => colours.directory().paint("d"),
- f::Type::Pipe => colours.pipe().paint("|"),
- f::Type::Link => colours.symlink().paint("l"),
- f::Type::BlockDevice => colours.block_device().paint("b"),
- f::Type::CharDevice => colours.char_device().paint("c"),
- f::Type::Socket => colours.socket().paint("s"),
- f::Type::Special => colours.special().paint("?"),
+ Self::File => colours.normal().paint("."),
+ Self::Directory => colours.directory().paint("d"),
+ Self::Pipe => colours.pipe().paint("|"),
+ Self::Link => colours.symlink().paint("l"),
+ Self::BlockDevice => colours.block_device().paint("b"),
+ Self::CharDevice => colours.char_device().paint("c"),
+ Self::Socket => colours.socket().paint("s"),
+ Self::Special => colours.special().paint("?"),
}
}
}
diff --git a/src/output/render/git.rs b/src/output/render/git.rs
index 1d24a32..ddeec01 100644
--- a/src/output/render/git.rs
+++ b/src/output/render/git.rs
@@ -20,14 +20,14 @@ impl f::Git {
impl f::GitStatus {
fn render(&self, colours: &dyn Colours) -> ANSIString<'static> {
match *self {
- f::GitStatus::NotModified => colours.not_modified().paint("-"),
- f::GitStatus::New => colours.new().paint("N"),
- f::GitStatus::Modified => colours.modified().paint("M"),
- f::GitStatus::Deleted => colours.deleted().paint("D"),
- f::GitStatus::Renamed => colours.renamed().paint("R"),
- f::GitStatus::TypeChange => colours.type_change().paint("T"),
- f::GitStatus::Ignored => colours.ignored().paint("I"),
- f::GitStatus::Conflicted => colours.conflicted().paint("U"),
+ Self::NotModified => colours.not_modified().paint("-"),
+ Self::New => colours.new().paint("N"),
+ Self::Modified => colours.modified().paint("M"),
+ Self::Deleted => colours.deleted().paint("D"),
+ Self::Renamed => colours.renamed().paint("R"),
+ Self::TypeChange => colours.type_change().paint("T"),
+ Self::Ignored => colours.ignored().paint("I"),
+ Self::Conflicted => colours.conflicted().paint("U"),
}
}
}
diff --git a/src/output/render/size.rs b/src/output/render/size.rs
index d44ecd3..969a489 100644
--- a/src/output/render/size.rs
+++ b/src/output/render/size.rs
@@ -12,9 +12,9 @@ impl f::Size {
use number_prefix::NumberPrefix;
let size = match *self {
- f::Size::Some(s) => s,
- f::Size::None => return TextCell::blank(colours.no_size()),
- f::Size::DeviceIDs(ref ids) => return ids.render(colours),
+ Self::Some(s) => s,
+ Self::None => return TextCell::blank(colours.no_size()),
+ Self::DeviceIDs(ref ids) => return ids.render(colours),
};
let result = match size_format {
diff --git a/src/output/table.rs b/src/output/table.rs
index 984c6a2..8caad45 100644
--- a/src/output/table.rs
+++ b/src/output/table.rs
@@ -144,12 +144,12 @@ impl Column {
/// Get the alignment this column should use.
pub fn alignment(&self) -> Alignment {
match *self {
- Column::FileSize
- | Column::HardLinks
- | Column::Inode
- | Column::Blocks
- | Column::GitStatus => Alignment::Right,
- _ => Alignment::Left,
+ Self::FileSize |
+ Self::HardLinks |
+ Self::Inode |
+ Self::Blocks |
+ Self::GitStatus => Alignment::Right,
+ _ => Alignment::Left,
}
}
@@ -157,16 +157,16 @@ impl Column {
/// to have a header row printed.
pub fn header(&self) -> &'static str {
match *self {
- Column::Permissions => "Permissions",
- Column::FileSize => "Size",
- Column::Timestamp(t) => t.header(),
- Column::Blocks => "Blocks",
- Column::User => "User",
- Column::Group => "Group",
- Column::HardLinks => "Links",
- Column::Inode => "inode",
- Column::GitStatus => "Git",
- Column::Octal => "Octal",
+ Self::Permissions => "Permissions",
+ Self::FileSize => "Size",
+ Self::Timestamp(t) => t.header(),
+ Self::Blocks => "Blocks",
+ Self::User => "User",
+ Self::Group => "Group",
+ Self::HardLinks => "Links",
+ Self::Inode => "inode",
+ Self::GitStatus => "Git",
+ Self::Octal => "Octal",
}
}
}
@@ -189,8 +189,8 @@ pub enum SizeFormat {
}
impl Default for SizeFormat {
- fn default() -> SizeFormat {
- SizeFormat::DecimalBytes
+ fn default() -> Self {
+ Self::DecimalBytes
}
}
@@ -217,10 +217,10 @@ impl TimeType {
/// Returns the text to use for a column’s heading in the columns output.
pub fn header(self) -> &'static str {
match self {
- TimeType::Modified => "Date Modified",
- TimeType::Changed => "Date Changed",
- TimeType::Accessed => "Date Accessed",
- TimeType::Created => "Date Created",
+ Self::Modified => "Date Modified",
+ Self::Changed => "Date Changed",
+ Self::Accessed => "Date Accessed",
+ Self::Created => "Date Created",
}
}
}
@@ -243,8 +243,8 @@ impl Default for TimeTypes {
/// By default, display just the ‘modified’ time. This is the most
/// common option, which is why it has this shorthand.
- fn default() -> TimeTypes {
- TimeTypes { modified: true, changed: false, accessed: false, created: false }
+ fn default() -> Self {
+ Self { modified: true, changed: false, accessed: false, created: false }
}
}
@@ -287,7 +287,7 @@ impl Environment {
let users = Mutex::new(UsersCache::new());
- Environment { tz, numeric, users }
+ Self { tz, numeric, users }
}
}
@@ -425,8 +425,8 @@ impl Deref for TableWidths {
}
impl TableWidths {
- pub fn zero(count: usize) -> TableWidths {
- TableWidths(vec![ 0; count ])
+ pub fn zero(count: usize) -> Self {
+ Self(vec![ 0; count ])
}
pub fn add_widths(&mut self, row: &Row) {
diff --git a/src/output/time.rs b/src/output/time.rs
index 48d9310..551b548 100644
--- a/src/output/time.rs
+++ b/src/output/time.rs
@@ -52,19 +52,19 @@ pub enum TimeFormat {
impl TimeFormat {
pub fn format_local(&self, time: SystemTime) -> String {
match *self {
- TimeFormat::DefaultFormat(ref fmt) => fmt.format_local(time),
- TimeFormat::ISOFormat(ref iso) => iso.format_local(time),
- TimeFormat::LongISO => long_local(time),
- TimeFormat::FullISO => full_local(time),
+ Self::DefaultFormat(ref fmt) => fmt.format_local(time),
+ Self::ISOFormat(ref iso) => iso.format_local(time),
+ Self::LongISO => long_local(time),
+ Self::FullISO => full_local(time),
}
}
pub fn format_zoned(&self, time: SystemTime, zone: &TimeZone) -> String {
match *self {
- TimeFormat::DefaultFormat(ref fmt) => fmt.format_zoned(time, zone),
- TimeFormat::ISOFormat(ref iso) => iso.format_zoned(time, zone),
- TimeFormat::LongISO => long_zoned(time, zone),
- TimeFormat::FullISO => full_zoned(time, zone),
+ Self::DefaultFormat(ref fmt) => fmt.format_zoned(time, zone),
+ Self::ISOFormat(ref iso) => iso.format_zoned(time, zone),
+ Self::LongISO => long_zoned(time, zone),
+ Self::FullISO => full_zoned(time, zone),
}
}
}
@@ -88,7 +88,7 @@ pub struct DefaultFormat {
}
impl DefaultFormat {
- pub fn load() -> DefaultFormat {
+ pub fn load() -> Self {
use unicode_width::UnicodeWidthStr;
let locale = locale::Time::load_user_locale()
@@ -117,7 +117,7 @@ impl DefaultFormat {
_ => DateFormat::parse("{2>:D} {:M} {5>:Y}").unwrap()
};
- DefaultFormat { current_year, locale, date_and_time, date_and_year }
+ Self { current_year, locale, date_and_time, date_and_year }
}
}
@@ -150,7 +150,7 @@ impl DefaultFormat {
if self.is_recent(date) {
format!("{:2} {} {:02}:{:02}",
- date.day(), DefaultFormat::month_to_abbrev(date.month()),
+ date.day(), Self::month_to_abbrev(date.month()),
date.hour(), date.minute())
}
else {
@@ -164,7 +164,7 @@ impl DefaultFormat {
if self.is_recent(date) {
format!("{:2} {} {:02}:{:02}",
- date.day(), DefaultFormat::month_to_abbrev(date.month()),
+ date.day(), Self::month_to_abbrev(date.month()),
date.hour(), date.minute())
}
else {
@@ -250,9 +250,9 @@ pub struct ISOFormat {
}
impl ISOFormat {
- pub fn load() -> ISOFormat {
+ pub fn load() -> Self {
let current_year = LocalDateTime::now().year();
- ISOFormat { current_year }
+ Self { current_year }
}
}
diff --git a/src/output/tree.rs b/src/output/tree.rs
index f786552..5a27fcb 100644
--- a/src/output/tree.rs
+++ b/src/output/tree.rs
@@ -61,10 +61,10 @@ impl TreePart {
/// (Warning: not actually ASCII)
pub fn ascii_art(&self) -> &'static str {
match *self {
- TreePart::Edge => "├──",
- TreePart::Line => "│ ",
- TreePart::Corner => "└──",
- TreePart::Blank => " ",
+ Self::Edge => "├──",
+ Self::Line => "│ ",
+ Self::Corner => "└──",
+ Self::Blank => " ",
}
}
}
@@ -138,8 +138,8 @@ impl TreeTrunk {
}
impl TreeParams {
- pub fn new(depth: TreeDepth, last: bool) -> TreeParams {
- TreeParams { depth, last }
+ pub fn new(depth: TreeDepth, last: bool) -> Self {
+ Self { depth, last }
}
pub fn is_at_root(&self) -> bool {
@@ -148,12 +148,12 @@ impl TreeParams {
}
impl TreeDepth {
- pub fn root() -> TreeDepth {
- TreeDepth(0)
+ pub fn root() -> Self {
+ Self(0)
}
- pub fn deeper(self) -> TreeDepth {
- TreeDepth(self.0 + 1)
+ pub fn deeper(self) -> Self {
+ Self(self.0 + 1)
}
/// Creates an iterator that, as well as yielding each value, yields a
diff --git a/src/style/colours.rs b/src/style/colours.rs
index debda16..4190330 100644
--- a/src/style/colours.rs
+++ b/src/style/colours.rs
@@ -109,12 +109,12 @@ pub struct Git {
}
impl Colours {
- pub fn plain() -> Colours {
- Colours::default()
+ pub fn plain() -> Self {
+ Self::default()
}
- pub fn colourful(scale: bool) -> Colours {
- Colours {
+ pub fn colourful(scale: bool) -> Self {
+ Self {
colourful: true,
filekinds: FileKinds {