Safely derive `Eq` whenever we derive `PartialEq`

This commit is contained in:
Victor Song 2022-09-30 22:46:59 -04:00
parent 89bcc00e32
commit cd715a6e00
20 changed files with 45 additions and 45 deletions

View File

@ -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 `..`.

View File

@ -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

View File

@ -210,7 +210,7 @@ pub struct Time {
/// A files 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 hasnt changed since the last commit.

View File

@ -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 {
/// Dont 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 isnt 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.

View File

@ -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 {

View File

@ -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 {

View File

@ -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 sections help.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct HelpString;
impl HelpString {

View File

@ -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,

View File

@ -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 doesnt 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 users 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 users command-line strings.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Matches<'args> {
/// The flags that were parsed from the users 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 users input, in the order they were
@ -462,7 +462,7 @@ impl<'a> MatchedFlags<'a> {
/// A problem with the users input that meant it couldnt 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.

View File

@ -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 arent anymore!

View File

@ -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 {

View File

@ -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.

View File

@ -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 {
/// Dont show icons at all.

View File

@ -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,
}

View File

@ -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 its harder to see whats 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

View File

@ -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.

View File

@ -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 files 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 files modified time (`st_mtime`).
@ -269,7 +269,7 @@ impl TimeType {
///
/// There should always be at least one of these — theres 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,

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, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum TimeFormat {
/// The **default format** uses the users locale to print month names,

View File

@ -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.

View File

@ -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 isnt 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>,