Skip to content

Commit ae7238b

Browse files
committed
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
1 parent dfd5885 commit ae7238b

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/uu/od/src/formatteriteminfo.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use std::fmt;
88

99
#[allow(clippy::enum_variant_names)]
10-
#[derive(Copy)]
10+
#[derive(Copy, PartialEq, Eq)]
1111
pub enum FormatWriter {
1212
IntWriter(fn(u64) -> String),
1313
FloatWriter(fn(f64) -> String),
@@ -21,21 +21,6 @@ impl Clone for FormatWriter {
2121
}
2222
}
2323

24-
impl PartialEq for FormatWriter {
25-
fn eq(&self, other: &Self) -> bool {
26-
use crate::formatteriteminfo::FormatWriter::*;
27-
28-
match (self, other) {
29-
(IntWriter(a), IntWriter(b)) => a == b,
30-
(FloatWriter(a), FloatWriter(b)) => a == b,
31-
(MultibyteWriter(a), MultibyteWriter(b)) => *a as usize == *b as usize,
32-
_ => false,
33-
}
34-
}
35-
}
36-
37-
impl Eq for FormatWriter {}
38-
3924
impl fmt::Debug for FormatWriter {
4025
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4126
match *self {

0 commit comments

Comments
 (0)