From cd715a6e0036aa474a33d1f4735be27674a8c704 Mon Sep 17 00:00:00 2001 From: Victor Song Date: Fri, 30 Sep 2022 22:46:59 -0400 Subject: [PATCH] Safely derive `Eq` whenever we derive `PartialEq` --- src/fs/dir.rs | 2 +- src/fs/dir_action.rs | 4 ++-- src/fs/fields.rs | 2 +- src/fs/filter.rs | 10 +++++----- src/info/filetype.rs | 2 +- src/options/error.rs | 6 +++--- src/options/help.rs | 2 +- src/options/mod.rs | 2 +- src/options/parser.rs | 16 ++++++++-------- src/options/version.rs | 2 +- src/output/cell.rs | 2 +- src/output/details.rs | 2 +- src/output/file_name.rs | 4 ++-- src/output/grid.rs | 2 +- src/output/grid_details.rs | 4 ++-- src/output/mod.rs | 4 ++-- src/output/table.rs | 12 ++++++------ src/output/time.rs | 2 +- src/output/tree.rs | 2 +- src/theme/mod.rs | 8 ++++---- 20 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/fs/dir.rs b/src/fs/dir.rs index fcb393f..9d4d4f2 100644 --- a/src/fs/dir.rs +++ b/src/fs/dir.rs @@ -176,7 +176,7 @@ impl<'dir, 'ig> Iterator for Files<'dir, 'ig> { /// Usually files in Unix use a leading dot to be hidden or visible, but two /// entries in particular are “extra-hidden”: `.` and `..`, which only become /// visible after an extra `-a` option. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum DotFilter { /// Shows files, dotfiles, and `.` and `..`. diff --git a/src/fs/dir_action.rs b/src/fs/dir_action.rs index ab8ceda..6e10403 100644 --- a/src/fs/dir_action.rs +++ b/src/fs/dir_action.rs @@ -19,7 +19,7 @@ /// into them and print out their contents. The recurse mode does this by /// having extra output blocks at the end, while the tree mode will show /// directories inline, with their contents immediately underneath. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum DirAction { /// This directory should be listed along with the regular files, instead @@ -58,7 +58,7 @@ impl DirAction { /// The options that determine how to recurse into a directory. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub struct RecurseOptions { /// Whether recursion should be done as a tree or as multiple individual diff --git a/src/fs/fields.rs b/src/fs/fields.rs index 6ad41e3..9369ecb 100644 --- a/src/fs/fields.rs +++ b/src/fs/fields.rs @@ -210,7 +210,7 @@ pub struct Time { /// A file’s status in a Git repository. Whether a file is in a repository or /// not is handled by the Git module, rather than having a “null” variant in /// this enum. -#[derive(PartialEq, Copy, Clone)] +#[derive(PartialEq, Eq, Copy, Clone)] pub enum GitStatus { /// This file hasn’t changed since the last commit. diff --git a/src/fs/filter.rs b/src/fs/filter.rs index 9662931..d3f831b 100644 --- a/src/fs/filter.rs +++ b/src/fs/filter.rs @@ -23,7 +23,7 @@ use crate::fs::File; /// The filter also governs sorting the list. After being filtered, pairs of /// files are compared and sorted based on the result, with the sort field /// performing the comparison. -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub struct FileFilter { /// Whether directories should be listed first, and other types of file @@ -113,7 +113,7 @@ impl FileFilter { /// User-supplied field to sort by. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum SortField { /// Don’t apply any sorting. This is usually used as an optimisation in @@ -194,7 +194,7 @@ pub enum SortField { /// lowercase letters because it takes the difference between the two cases /// into account? I gave up and just named these two variants after the /// effects they have. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum SortCase { /// Sort files case-sensitively with uppercase first, with ‘A’ coming @@ -271,7 +271,7 @@ impl SortField { /// The **ignore patterns** are a list of globs that are tested against /// each filename, and if any of them match, that file isn’t displayed. /// This lets a user hide, say, text files by ignoring `*.txt`. -#[derive(PartialEq, Default, Debug, Clone)] +#[derive(PartialEq, Eq, Default, Debug, Clone)] pub struct IgnorePatterns { patterns: Vec, } @@ -327,7 +327,7 @@ impl IgnorePatterns { /// Whether to ignore or display files that Git would ignore. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum GitIgnore { /// Ignore files that Git would ignore. diff --git a/src/info/filetype.rs b/src/info/filetype.rs index d7d2a4d..9223fdc 100644 --- a/src/info/filetype.rs +++ b/src/info/filetype.rs @@ -11,7 +11,7 @@ use crate::output::icons::FileIcon; use crate::theme::FileColours; -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, Default, PartialEq, Eq)] pub struct FileExtensions; impl FileExtensions { diff --git a/src/options/error.rs b/src/options/error.rs index 1b1aa87..2721282 100644 --- a/src/options/error.rs +++ b/src/options/error.rs @@ -7,7 +7,7 @@ use crate::options::parser::{Arg, Flag, ParseError}; /// Something wrong with the combination of options the user has picked. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum OptionsError { /// There was an error (from `getopts`) parsing the arguments. @@ -44,7 +44,7 @@ pub enum OptionsError { } /// The source of a string that failed to be parsed as a number. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum NumberSource { /// It came... from a command-line argument! @@ -119,7 +119,7 @@ impl OptionsError { /// A list of legal choices for an argument-taking option. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Choices(pub &'static [&'static str]); impl fmt::Display for Choices { diff --git a/src/options/help.rs b/src/options/help.rs index f3f4009..0299393 100644 --- a/src/options/help.rs +++ b/src/options/help.rs @@ -69,7 +69,7 @@ static EXTENDED_HELP: &str = " -@, --extended list each file's extended /// All the information needed to display the help text, which depends /// on which features are enabled and whether the user only wants to /// see one section’s help. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub struct HelpString; impl HelpString { diff --git a/src/options/mod.rs b/src/options/mod.rs index 528ba43..5c060b6 100644 --- a/src/options/mod.rs +++ b/src/options/mod.rs @@ -216,7 +216,7 @@ pub mod test { use crate::options::parser::{Arg, MatchedFlags}; use std::ffi::OsStr; - #[derive(PartialEq, Debug)] + #[derive(PartialEq, Eq, Debug)] pub enum Strictnesses { Last, Complain, diff --git a/src/options/parser.rs b/src/options/parser.rs index 63a1606..ca0029b 100644 --- a/src/options/parser.rs +++ b/src/options/parser.rs @@ -52,7 +52,7 @@ pub type Values = &'static [&'static str]; /// A **flag** is either of the two argument types, because they have to /// be in the same array together. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum Flag { Short(ShortArg), Long(LongArg), @@ -77,7 +77,7 @@ impl fmt::Display for Flag { } /// Whether redundant arguments should be considered a problem. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum Strictness { /// Throw an error when an argument doesn’t do anything, either because @@ -91,7 +91,7 @@ pub enum Strictness { /// Whether a flag takes a value. This is applicable to both long and short /// arguments. -#[derive(Copy, Clone, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum TakesValue { /// This flag has to be followed by a value. @@ -108,7 +108,7 @@ pub enum TakesValue { /// An **argument** can be matched by one of the user’s input strings. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub struct Arg { /// The short argument that matches it, if any. @@ -136,7 +136,7 @@ impl fmt::Display for Arg { /// Literally just several args. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Args(pub &'static [&'static Arg]); impl Args { @@ -340,7 +340,7 @@ impl Args { /// The **matches** are the result of parsing the user’s command-line strings. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Matches<'args> { /// The flags that were parsed from the user’s input. @@ -351,7 +351,7 @@ pub struct Matches<'args> { pub frees: Vec<&'args OsStr>, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct MatchedFlags<'args> { /// The individual flags from the user’s input, in the order they were @@ -462,7 +462,7 @@ impl<'a> MatchedFlags<'a> { /// A problem with the user’s input that meant it couldn’t be parsed into a /// coherent list of arguments. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum ParseError { /// A flag that has to take a value was not given one. diff --git a/src/options/version.rs b/src/options/version.rs index 2214164..3b78c3a 100644 --- a/src/options/version.rs +++ b/src/options/version.rs @@ -8,7 +8,7 @@ use crate::options::flags; use crate::options::parser::MatchedFlags; -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub struct VersionString; // There were options here once, but there aren’t anymore! diff --git a/src/output/cell.rs b/src/output/cell.rs index c8d2675..f515014 100644 --- a/src/output/cell.rs +++ b/src/output/cell.rs @@ -193,7 +193,7 @@ impl TextCellContents { /// /// It has `From` impls that convert an input string or fixed with to values /// of this type, and will `Deref` to the contained `usize` value. -#[derive(PartialEq, Debug, Clone, Copy, Default)] +#[derive(PartialEq, Eq, Debug, Clone, Copy, Default)] pub struct DisplayWidth(usize); impl<'a> From<&'a str> for DisplayWidth { diff --git a/src/output/details.rs b/src/output/details.rs index 62ef7d8..f86a202 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -91,7 +91,7 @@ use crate::theme::Theme; /// /// Almost all the heavy lifting is done in a Table object, which handles the /// columns for each row. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Options { /// Options specific to drawing a table. diff --git a/src/output/file_name.rs b/src/output/file_name.rs index eeb359b..6eeaf1b 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -54,7 +54,7 @@ enum LinkStyle { /// Whether to append file class characters to the file names. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum Classify { /// Just display the file names, without any characters. @@ -73,7 +73,7 @@ impl Default for Classify { /// Whether and how to show icons. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum ShowIcons { /// Don’t show icons at all. diff --git a/src/output/grid.rs b/src/output/grid.rs index 0e1b694..f53ccfa 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -8,7 +8,7 @@ use crate::output::file_name::Options as FileStyle; use crate::theme::Theme; -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub struct Options { pub across: bool, } diff --git a/src/output/grid_details.rs b/src/output/grid_details.rs index fd096da..94c1b79 100644 --- a/src/output/grid_details.rs +++ b/src/output/grid_details.rs @@ -18,7 +18,7 @@ use crate::output::tree::{TreeParams, TreeDepth}; use crate::theme::Theme; -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Options { pub grid: GridOptions, pub details: DetailsOptions, @@ -39,7 +39,7 @@ impl Options { /// small directory of four files in four columns, the files just look spaced /// out and it’s harder to see what’s going on. So it can be enabled just for /// larger directory listings. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum RowThreshold { /// Only use grid-details view if it would result in at least this many diff --git a/src/output/mod.rs b/src/output/mod.rs index 2c64010..331d2fd 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -26,7 +26,7 @@ pub struct View { /// The **mode** is the “type” of output. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[allow(clippy::large_enum_variant)] pub enum Mode { Grid(grid::Options), @@ -37,7 +37,7 @@ pub enum Mode { /// The width of the terminal requested by the user. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum TerminalWidth { /// The user requested this specific number of columns. diff --git a/src/output/table.rs b/src/output/table.rs index 6bd1f8e..b502c52 100644 --- a/src/output/table.rs +++ b/src/output/table.rs @@ -21,7 +21,7 @@ use crate::theme::Theme; /// Options for displaying a table. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Options { pub size_format: SizeFormat, pub time_format: TimeFormat, @@ -31,7 +31,7 @@ pub struct Options { /// Extra columns to display in the table. #[allow(clippy::struct_excessive_bools)] -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub struct Columns { /// At least one of these timestamps will be shown. @@ -201,7 +201,7 @@ impl Column { /// Formatting options for file sizes. #[allow(clippy::pub_enum_variant_names)] -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum SizeFormat { /// Format the file size using **decimal** prefixes, such as “kilo”, @@ -217,7 +217,7 @@ pub enum SizeFormat { } /// Formatting options for user and group. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum UserFormat { /// The UID / GID Numeric, @@ -234,7 +234,7 @@ impl Default for SizeFormat { /// The types of a file’s time fields. These three fields are standard /// across most (all?) operating systems. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum TimeType { /// The file’s modified time (`st_mtime`). @@ -269,7 +269,7 @@ impl TimeType { /// /// There should always be at least one of these — there’s no way to disable /// the time columns entirely (yet). -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] #[allow(clippy::struct_excessive_bools)] pub struct TimeTypes { pub modified: bool, diff --git a/src/output/time.rs b/src/output/time.rs index cb18c54..bb3ee61 100644 --- a/src/output/time.rs +++ b/src/output/time.rs @@ -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, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum TimeFormat { /// The **default format** uses the user’s locale to print month names, diff --git a/src/output/tree.rs b/src/output/tree.rs index 209b82c..360a8c4 100644 --- a/src/output/tree.rs +++ b/src/output/tree.rs @@ -39,7 +39,7 @@ //! each directory) -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum TreePart { /// Rightmost column, *not* the last in the directory. diff --git a/src/theme/mod.rs b/src/theme/mod.rs index 6f282d9..243698e 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -14,7 +14,7 @@ pub use self::lsc::LSColors; mod default_theme; -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Options { pub use_colours: UseColours, @@ -31,7 +31,7 @@ pub struct Options { /// Turning them on when output is going to, say, a pipe, would make programs /// such as `grep` or `more` not work properly. So the `Automatic` mode does /// this check and only displays colours when they can be truly appreciated. -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum UseColours { /// Display them even when output isn’t going to a terminal. @@ -44,13 +44,13 @@ pub enum UseColours { Never, } -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum ColourScale { Fixed, Gradient, } -#[derive(PartialEq, Debug, Default)] +#[derive(PartialEq, Eq, Debug, Default)] pub struct Definitions { pub ls: Option, pub exa: Option,