From 69371e75be56caecd243645c032f1fbcb2645a66 Mon Sep 17 00:00:00 2001 From: ivmarkov Date: Sun, 7 Sep 2025 06:16:01 +0000 Subject: [PATCH] Clippy and derive more --- src/can.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/can.rs b/src/can.rs index 5c105c297..71108a7bc 100644 --- a/src/can.rs +++ b/src/can.rs @@ -66,13 +66,14 @@ pub mod config { use super::Alert; /// CAN timing - #[derive(Debug, Copy, Clone, Eq, PartialEq)] + #[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Timing { B25K, B50K, B100K, B125K, B250K, + #[default] B500K, B800K, B1M, @@ -163,12 +164,6 @@ pub mod config { } } - impl Default for Timing { - fn default() -> Self { - Self::B500K - } - } - /// Is used to filter out unwanted CAN IDs (messages). /// /// Notice that Espressif TWAI (CAN in rest of the world) acceptance filtering @@ -215,7 +210,7 @@ pub mod config { /// let mask = 0x7F0; /// let f = Filter::Standard { filter, mask }; /// ``` - #[derive(Debug, Copy, Clone, Eq, PartialEq)] + #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Filter { /// Filter for 11 bit standard CAN IDs Standard { filter: u16, mask: u16 }, @@ -232,12 +227,12 @@ pub mod config { impl Filter { /// Filter that allows all standard CAN IDs. - pub fn standard_allow_all() -> Self { + pub const fn standard_allow_all() -> Self { Self::Standard { filter: 0, mask: 0 } } /// Filter that accepts all extended CAN IDs. - pub fn extended_allow_all() -> Self { + pub const fn extended_allow_all() -> Self { Self::Extended { filter: 0, mask: 0 } } } @@ -248,7 +243,7 @@ pub mod config { } } - #[derive(Debug, Copy, Clone, Default)] + #[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)] pub enum Mode { #[default] Normal,