Browse Source

Safely derive `Eq` whenever we derive `PartialEq`

Victor Song 3 years ago
parent
commit
cd715a6e00

+ 1 - 1
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 `..`.

+ 2 - 2
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

+ 1 - 1
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.

+ 5 - 5
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<glob::Pattern>,
 }
@@ -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.

+ 1 - 1
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 {

+ 3 - 3
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 {

+ 1 - 1
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 {

+ 1 - 1
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,

+ 8 - 8
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.

+ 1 - 1
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!
 

+ 1 - 1
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 {

+ 1 - 1
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.

+ 2 - 2
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.

+ 1 - 1
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,
 }

+ 2 - 2
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

+ 2 - 2
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.

+ 6 - 6
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,

+ 1 - 1
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,

+ 1 - 1
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.

+ 4 - 4
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<String>,
     pub exa: Option<String>,