From ae7238bbdf05c67f8df340abb23568faff5bf7ca Mon Sep 17 00:00:00 2001 From: Alexander Shirokov Date: Sun, 26 Jan 2025 11:42:35 +0100 Subject: [PATCH] od:use derived PartialEq and Eq Removing custom PartialEq and Eq implementations helps avoid issues like: help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | 29 | (IntWriter(a), IntWriter(b)) => std::ptr::fn_addr_eq(*a, *b), | ++++++++++++++++++++++ ~~~ + Observable on nightly 1.86 --- src/uu/od/src/formatteriteminfo.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/uu/od/src/formatteriteminfo.rs b/src/uu/od/src/formatteriteminfo.rs index 9e3c2e836..4f53397dd 100644 --- a/src/uu/od/src/formatteriteminfo.rs +++ b/src/uu/od/src/formatteriteminfo.rs @@ -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), @@ -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 {