Skip to content

Commit

Permalink
Merge pull request uutils#7211 from alexs-sh/od-use-derived-cmp
Browse files Browse the repository at this point in the history
od:remove custom implementations of PartialEq and Eq
  • Loading branch information
sylvestre authored Jan 26, 2025
2 parents dfd5885 + ae7238b commit 2430e2a
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/uu/od/src/formatteriteminfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::fmt;

#[allow(clippy::enum_variant_names)]
#[derive(Copy)]
#[derive(Copy, PartialEq, Eq)]
pub enum FormatWriter {
IntWriter(fn(u64) -> String),
FloatWriter(fn(f64) -> String),
Expand All @@ -21,21 +21,6 @@ impl Clone for FormatWriter {
}
}

impl PartialEq for FormatWriter {
fn eq(&self, other: &Self) -> bool {
use crate::formatteriteminfo::FormatWriter::*;

match (self, other) {
(IntWriter(a), IntWriter(b)) => a == b,
(FloatWriter(a), FloatWriter(b)) => a == b,
(MultibyteWriter(a), MultibyteWriter(b)) => *a as usize == *b as usize,
_ => false,
}
}
}

impl Eq for FormatWriter {}

impl fmt::Debug for FormatWriter {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Expand Down

0 comments on commit 2430e2a

Please sign in to comment.