From 28c4116565bfe71ef7328f4a34458501ef3dc5b0 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Tue, 16 Dec 2025 14:02:18 +0000 Subject: fixed clippy warnings --- src/command_policy.rs | 7 ++----- src/entity_switch.rs | 10 +--------- src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/command_policy.rs b/src/command_policy.rs index 049d56a..e5859bb 100644 --- a/src/command_policy.rs +++ b/src/command_policy.rs @@ -64,16 +64,13 @@ /// # async fn turn_on_motor() -> Result<(), ()> { Ok(()) } /// ``` #[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Default)] pub enum CommandPolicy { /// Automatically publish the entity's state when a command is received. + #[default] PublishState, /// Do not automatically publish state. The application must manually update the state. Manual, } -impl Default for CommandPolicy { - fn default() -> Self { - Self::PublishState - } -} diff --git a/src/entity_switch.rs b/src/entity_switch.rs index c1531eb..2b799a1 100644 --- a/src/entity_switch.rs +++ b/src/entity_switch.rs @@ -15,21 +15,13 @@ pub enum SwitchClass { /// /// See [`CommandPolicy`] for details on how commands are handled. #[derive(Debug)] +#[derive(Default)] pub struct SwitchConfig { pub common: EntityCommonConfig, pub class: SwitchClass, pub command_policy: CommandPolicy, } -impl Default for SwitchConfig { - fn default() -> Self { - Self { - common: Default::default(), - class: Default::default(), - command_policy: CommandPolicy::default(), - } - } -} impl SwitchConfig { pub(crate) fn populate(&self, config: &mut EntityConfig) { diff --git a/src/lib.rs b/src/lib.rs index 1b7c79a..edc60f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1047,7 +1047,7 @@ pub async fn run(device: &mut Device<'_>, transport: &mut T) -> Re .resize(device.publish_buffer.capacity(), 0) .expect("resize to capacity should never fail"); let n = - serde_json_core::to_slice(&tracker_state, &mut device.publish_buffer) + serde_json_core::to_slice(&tracker_state, device.publish_buffer) .expect("publish buffer too small for tracker state payload"); device.publish_buffer.truncate(n); } -- cgit