From 9719c461368b318ae0bc476c7e94e2dbbef88e84 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sat, 30 Nov 2024 05:30:53 +0100 Subject: [PATCH] Added deref to impl_device to account for changes in mlua 0.10 --- src/devices/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 88f5375..6281992 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -13,6 +13,7 @@ mod wake_on_lan; mod washer; use std::fmt::Debug; +use std::ops::Deref; use async_trait::async_trait; use automation_cast::Cast; @@ -74,8 +75,8 @@ macro_rules! impl_device { if impls::impls!($device: OnOff) { methods.add_async_method("set_on", |_lua, this, on: bool| async move { - (this.cast() as Option<&dyn OnOff>) - .unwrap() + (this.deref().cast() as Option<&dyn OnOff>) + .expect("Cast should be valid") .set_on(on) .await .unwrap(); @@ -84,8 +85,8 @@ macro_rules! impl_device { }); methods.add_async_method("is_on", |_lua, this, _: ()| async move { - Ok((this.cast() as Option<&dyn OnOff>) - .unwrap() + Ok((this.deref().cast() as Option<&dyn OnOff>) + .expect("Cast should be valid") .on() .await .unwrap())