From 06f3f17d41c5a09fbaa4a280ad04300b900b1f08 Mon Sep 17 00:00:00 2001 From: Vitalii Lukyanov Date: Thu, 26 Sep 2024 18:46:32 +0200 Subject: [PATCH 1/8] macro refactor with support for generics and various attributes, including derives --- Cargo.lock | 90 ++++++++++++ iced_layershell/README.md | 5 +- iced_layershell_macros/Cargo.toml | 4 +- iced_layershell_macros/src/lib.rs | 230 +++++++++++++++--------------- 4 files changed, 210 insertions(+), 119 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f89a06b..a2311b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -913,6 +913,41 @@ dependencies = [ "zbus", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.77", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.77", +] + [[package]] name = "data-url" version = "0.3.1" @@ -1196,6 +1231,12 @@ dependencies = [ "spin", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "font-types" version = "0.6.0" @@ -1787,6 +1828,8 @@ dependencies = [ name = "iced_layershell_macros" version = "0.7.1" dependencies = [ + "darling", + "manyhow", "proc-macro2", "quote", "syn 2.0.77", @@ -1921,6 +1964,12 @@ dependencies = [ "winit", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "image" version = "0.24.9" @@ -2238,6 +2287,30 @@ dependencies = [ "libc", ] +[[package]] +name = "manyhow" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b33efb3ca6d3b07393750d4030418d594ab1139cee518f0dc88db70fec873587" +dependencies = [ + "darling_core", + "manyhow-macros", + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "manyhow-macros" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fce34d199b78b6e6073abf984c9cf5fd3e9330145a93ee0738a7443e371495" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", +] + [[package]] name = "memchr" version = "2.7.4" @@ -3009,6 +3082,17 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-utils" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaf08a13de400bc215877b5bdc088f241b12eb42f0a548d3390dc1c56bb7071" +dependencies = [ + "proc-macro2", + "quote", + "smallvec", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -3659,6 +3743,12 @@ dependencies = [ "float-cmp", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "svg_fmt" version = "0.4.3" diff --git a/iced_layershell/README.md b/iced_layershell/README.md index 577cf41..01bddd2 100644 --- a/iced_layershell/README.md +++ b/iced_layershell/README.md @@ -58,7 +58,10 @@ enum WindowDirection { // Because new iced delete the custom command, so now we make a macro crate to generate // the Command -#[to_layer_message(derives = "Debug Clone")] +#[to_layer_message(attrs = " + derive(Debug, Clone) + | doc(\"Some docs\") +")] enum Message { IncrementPressed, DecrementPressed, diff --git a/iced_layershell_macros/Cargo.toml b/iced_layershell_macros/Cargo.toml index 6999e67..959e35a 100644 --- a/iced_layershell_macros/Cargo.toml +++ b/iced_layershell_macros/Cargo.toml @@ -13,6 +13,8 @@ readme.workspace = true proc-macro = true [dependencies] +darling = { version = "0.20.10", features = ["diagnostics", "suggestions"] } +manyhow = { version = "0.11.4", features = ["darling"] } proc-macro2 = "1.0.86" quote = "1.0.37" -syn = { version = "2.0.77", features = ["full"]} +syn = { version = "2.0.77", features = ["full"] } diff --git a/iced_layershell_macros/src/lib.rs b/iced_layershell_macros/src/lib.rs index c6f1e9f..09f1a13 100644 --- a/iced_layershell_macros/src/lib.rs +++ b/iced_layershell_macros/src/lib.rs @@ -1,53 +1,46 @@ -use proc_macro::TokenStream; -use proc_macro2::{Ident, Span}; -use syn::{parse_macro_input, ItemEnum, LitStr}; +use darling::{ + ast::{Data, NestedMeta}, + util::{Flag, Ignored}, + FromDeriveInput, FromMeta, +}; +use proc_macro2::{Span, TokenStream as TokenStream2}; +use syn::{ + punctuated::Punctuated, DeriveInput, Generics, Ident, LitStr, Meta, Token, Variant, Visibility, +}; use quote::quote; +#[manyhow::manyhow] #[proc_macro_attribute] -pub fn to_layer_message(attr: TokenStream, input: TokenStream) -> TokenStream { - let mut is_multi = false; - let mut info_name: Option = None; - let mut derives: Option = None; - let tea_parser = syn::meta::parser(|meta| { - if meta.path.is_ident("multi") { - is_multi = true; - Ok(()) - } else if meta.path.is_ident("info_name") { - info_name = Some(meta.value()?.parse()?); - Ok(()) - } else if meta.path.is_ident("derives") { - derives = Some(meta.value()?.parse()?); - Ok(()) - } else { - Err(meta.error("unsupported tea property")) - } - }); - let input_enum = parse_macro_input!(input as ItemEnum); - parse_macro_input!(attr with tea_parser); - let mut derive_part = vec![]; - if let Some(derives) = derives { - let tmpval = derives.value(); - let val: Vec<&str> = tmpval.split(' ').collect(); - for der in val.iter() { - let iden_tmp = Ident::new(der, Span::call_site()); - derive_part.push(quote! { - #[derive(#iden_tmp)] - }); - } - } - // Extract the enum name - let enum_vis = &input_enum.vis; - let enum_name = &input_enum.ident; - let variants = &input_enum.variants; - let new_varents = if is_multi { - let info_name = info_name.expect("Should set the infoName").value(); - let info = Ident::new(&info_name, Span::call_site()); - - quote! { - #(#derive_part)* - #enum_vis enum #enum_name { - #variants +pub fn to_layer_message(attr: TokenStream2, input: TokenStream2) -> manyhow::Result { + let meta = NestedMeta::parse_meta_list(attr)?; + + let ToLayerMessageAttr { + multi, + info_name, + attrs, + } = ToLayerMessageAttr::from_list(&meta)?; + + let is_multi = multi.is_present(); + let attrs = attrs.into_iter().map(|meta| quote!(#[#meta])); + + let derive_input = syn::parse2::(input)?; + let MessageEnum { + vis, + ident, + generics, + data, + } = MessageEnum::from_derive_input(&derive_input)?; + + let (impl_gen, ty_gen, where_gen) = generics.split_for_impl(); + let variants = data.take_enum().unwrap(); + + let (additional_variants, try_into_impl) = match is_multi { + true => { + let info_name = info_name.expect("Should set the info_name").value(); + let info = Ident::new(&info_name, Span::call_site()); + + let additional_variants = quote! { AnchorChange{id: iced::window::Id, anchor: iced_layershell::reexport::Anchor}, LayerChange{id: iced::window::Id, layer:iced_layershell::reexport::Layer}, MarginChange{id: iced::window::Id, margin: (i32, i32, i32, i32)}, @@ -61,52 +54,40 @@ pub fn to_layer_message(attr: TokenStream, input: TokenStream) -> TokenStream { NewMenu { settings: iced_layershell::actions::IcedNewMenuSettings, info: #info }, RemoveWindow(iced::window::Id), ForgetLastOutput, - } - impl TryInto> for #enum_name { - type Error = Self; - - fn try_into(self) -> Result, Self::Error> { - type InnerLayerActionId = iced_layershell::actions::LayershellCustomActionsWithIdAndInfo<#info>; - type InnerLayerAction = iced_layershell::actions::LayershellCustomActionsWithInfo<#info>; - match self { - Self::AnchorChange{id, anchor} => { - Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::AnchorChange(anchor))) - } - Self::LayerChange{id, layer} => { - Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::LayerChange(layer))) - } - Self::MarginChange{id, margin} => { - Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::MarginChange(margin))) - } - Self::SizeChange {id,size} => { - Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::SizeChange(size))) - } - Self::VirtualKeyboardPressed { - time, - key, - } => { - Ok(InnerLayerActionId::new(None, InnerLayerAction::VirtualKeyboardPressed { - time, - key - })) - } - Self::NewLayerShell {settings, info } => { - Ok(InnerLayerActionId::new(None, InnerLayerAction::NewLayerShell((settings, info)))) + }; + + let try_into_impl = quote! { + impl #impl_gen TryInto> for #ident #ty_gen #where_gen { + type Error = Self; + + fn try_into(self) -> Result, Self::Error> { + type InnerLayerActionId = iced_layershell::actions::LayershellCustomActionsWithIdAndInfo<#info>; + type InnerLayerAction = iced_layershell::actions::LayershellCustomActionsWithInfo<#info>; + + match self { + Self::AnchorChange { id, anchor } => Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::AnchorChange(anchor))), + Self::LayerChange { id, layer } => Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::LayerChange(layer))), + Self::MarginChange { id, margin } => Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::MarginChange(margin))), + Self::SizeChange { id, size } => Ok(InnerLayerActionId::new(Some(id), InnerLayerAction::SizeChange(size))), + Self::VirtualKeyboardPressed { time, key } => Ok(InnerLayerActionId::new( + None, + InnerLayerAction::VirtualKeyboardPressed { time, key }) + ), + Self::NewLayerShell {settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewLayerShell((settings, info)))), + Self::NewPopUp { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewPopUp((settings, info)))), + Self::NewMenu { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewMenu((settings, info)))), + Self::RemoveWindow(id) => Ok(InnerLayerActionId::new(None, InnerLayerAction::RemoveWindow(id))), + Self::ForgetLastOutput => Ok(InnerLayerActionId::new(None, InnerLayerAction::ForgetLastOutput)), + _ => Err(self) } - Self::NewPopUp { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewPopUp((settings, info)))), - Self::NewMenu { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewMenu((settings, info)))), - Self::RemoveWindow(id) => Ok(InnerLayerActionId::new(None, InnerLayerAction::RemoveWindow(id))), - Self::ForgetLastOutput => Ok(InnerLayerActionId::new(None, InnerLayerAction::ForgetLastOutput)), - _ => Err(self) } } - } + }; + + (additional_variants, try_into_impl) } - } else { - quote! { - #(#derive_part)* - #enum_vis enum #enum_name { - #variants + false => { + let additional_variants = quote! { AnchorChange(iced_layershell::reexport::Anchor), LayerChange(iced_layershell::reexport::Layer), MarginChange((i32, i32, i32, i32)), @@ -115,43 +96,58 @@ pub fn to_layer_message(attr: TokenStream, input: TokenStream) -> TokenStream { time: u32, key: u32, }, - } - - impl TryInto for #enum_name { - type Error = Self; - fn try_into(self) -> Result { - use iced_layershell::actions::LayershellCustomActions; - match self { - Self::AnchorChange(anchor) => { - Ok(LayershellCustomActions::AnchorChange(anchor)) - }, - Self::LayerChange(layer) => { - Ok(LayershellCustomActions::LayerChange(layer)) - } - Self::MarginChange(margin) => { - Ok(LayershellCustomActions::MarginChange(margin)) - } - Self::SizeChange(size) => { + }; + let try_into_impl = quote! { + impl #impl_gen TryInto for #ident #ty_gen #where_gen { + type Error = Self; - Ok(LayershellCustomActions::SizeChange(size)) - } - Self::VirtualKeyboardPressed { - time, - key, - } => { + fn try_into(self) -> Result { + use iced_layershell::actions::LayershellCustomActions; - Ok(LayershellCustomActions::VirtualKeyboardPressed { + match self { + Self::AnchorChange(anchor) => Ok(LayershellCustomActions::AnchorChange(anchor)), + Self::LayerChange(layer) => Ok(LayershellCustomActions::LayerChange(layer)), + Self::MarginChange(margin) => Ok(LayershellCustomActions::MarginChange(margin)), + Self::SizeChange(size) => Ok(LayershellCustomActions::SizeChange(size)), + Self::VirtualKeyboardPressed { time, key } => Ok(LayershellCustomActions::VirtualKeyboardPressed { time, key - }) + }), + _ => Err(self) } - _ => Err(self) } } - // add code here - } + }; + + (additional_variants, try_into_impl) } }; - TokenStream::from(new_varents) + Ok(quote! { + #(#attrs)* + #vis enum #ident #ty_gen #where_gen { + #(#variants,)* + #additional_variants + } + + #try_into_impl + }) +} + +#[derive(FromMeta)] +struct ToLayerMessageAttr { + multi: Flag, + info_name: Option, + + #[darling(default)] + attrs: Punctuated, +} + +#[derive(FromDeriveInput)] +#[darling(supports(enum_any))] +struct MessageEnum { + vis: Visibility, + ident: Ident, + generics: Generics, + data: Data, } From 954e4bfc31213366722aaf7220b1eb530c279852 Mon Sep 17 00:00:00 2001 From: Vitalii Lukyanov Date: Thu, 26 Sep 2024 18:47:34 +0200 Subject: [PATCH 2/8] misstype --- iced_layershell/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iced_layershell/README.md b/iced_layershell/README.md index 01bddd2..de8e23b 100644 --- a/iced_layershell/README.md +++ b/iced_layershell/README.md @@ -60,7 +60,7 @@ enum WindowDirection { // the Command #[to_layer_message(attrs = " derive(Debug, Clone) - | doc(\"Some docs\") + | doc = \"Some docs\" ")] enum Message { IncrementPressed, From 6757db262328aa89eea59aa54af6c00a5150c53d Mon Sep 17 00:00:00 2001 From: Vitalii Lukyanov Date: Thu, 26 Sep 2024 19:17:06 +0200 Subject: [PATCH 3/8] fixed tests that used the macro --- iced_examples/counter/src/main.rs | 2 +- iced_examples/counter_muti/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iced_examples/counter/src/main.rs b/iced_examples/counter/src/main.rs index 1b8985c..e1b5a3b 100644 --- a/iced_examples/counter/src/main.rs +++ b/iced_examples/counter/src/main.rs @@ -38,7 +38,7 @@ enum WindowDirection { Bottom, } -#[to_layer_message(derives = "Debug Clone")] +#[to_layer_message(attrs = "derive(Debug, Clone)")] enum Message { IncrementPressed, DecrementPressed, diff --git a/iced_examples/counter_muti/src/main.rs b/iced_examples/counter_muti/src/main.rs index 7ce2482..e2c9c09 100644 --- a/iced_examples/counter_muti/src/main.rs +++ b/iced_examples/counter_muti/src/main.rs @@ -44,7 +44,7 @@ enum WindowDirection { Bottom(Id), } -#[to_layer_message(multi, info_name = "WindowInfo", derives = "Debug Clone")] +#[to_layer_message(multi, info_name = "WindowInfo", attrs = "derive(Debug, Clone)")] enum Message { IncrementPressed, DecrementPressed, From 304436a7ecc6d30326387763e80662f62007db49 Mon Sep 17 00:00:00 2001 From: Vitalii Lukyanov Date: Thu, 26 Sep 2024 19:28:57 +0200 Subject: [PATCH 4/8] fixed build for stable, added diagnostics feature in case it is someone on nightly wants it enabled --- iced_layershell_macros/Cargo.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/iced_layershell_macros/Cargo.toml b/iced_layershell_macros/Cargo.toml index 959e35a..f82a9b3 100644 --- a/iced_layershell_macros/Cargo.toml +++ b/iced_layershell_macros/Cargo.toml @@ -12,8 +12,13 @@ readme.workspace = true [lib] proc-macro = true +[features] +default = [] +# Only nightly +diagnostics = ["darling/diagnostics"] + [dependencies] -darling = { version = "0.20.10", features = ["diagnostics", "suggestions"] } +darling = { version = "0.20.10", features = ["suggestions"] } manyhow = { version = "0.11.4", features = ["darling"] } proc-macro2 = "1.0.86" quote = "1.0.37" From 234dcbe1c12ad282685d3646468949709875abe5 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Fri, 27 Sep 2024 11:46:58 +0900 Subject: [PATCH 5/8] feat: attrs in macro by origin way --- iced_examples/counter/src/main.rs | 3 ++- iced_examples/counter_muti/src/main.rs | 3 ++- iced_layershell_macros/src/lib.rs | 15 +++------------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/iced_examples/counter/src/main.rs b/iced_examples/counter/src/main.rs index e1b5a3b..99156b5 100644 --- a/iced_examples/counter/src/main.rs +++ b/iced_examples/counter/src/main.rs @@ -38,7 +38,8 @@ enum WindowDirection { Bottom, } -#[to_layer_message(attrs = "derive(Debug, Clone)")] +#[to_layer_message] +#[derive(Debug, Clone)] enum Message { IncrementPressed, DecrementPressed, diff --git a/iced_examples/counter_muti/src/main.rs b/iced_examples/counter_muti/src/main.rs index e2c9c09..969abd5 100644 --- a/iced_examples/counter_muti/src/main.rs +++ b/iced_examples/counter_muti/src/main.rs @@ -44,7 +44,8 @@ enum WindowDirection { Bottom(Id), } -#[to_layer_message(multi, info_name = "WindowInfo", attrs = "derive(Debug, Clone)")] +#[to_layer_message(multi, info_name = "WindowInfo")] +#[derive(Debug, Clone)] enum Message { IncrementPressed, DecrementPressed, diff --git a/iced_layershell_macros/src/lib.rs b/iced_layershell_macros/src/lib.rs index 09f1a13..73f88c5 100644 --- a/iced_layershell_macros/src/lib.rs +++ b/iced_layershell_macros/src/lib.rs @@ -4,9 +4,7 @@ use darling::{ FromDeriveInput, FromMeta, }; use proc_macro2::{Span, TokenStream as TokenStream2}; -use syn::{ - punctuated::Punctuated, DeriveInput, Generics, Ident, LitStr, Meta, Token, Variant, Visibility, -}; +use syn::{DeriveInput, Generics, Ident, LitStr, Variant, Visibility}; use quote::quote; @@ -15,16 +13,12 @@ use quote::quote; pub fn to_layer_message(attr: TokenStream2, input: TokenStream2) -> manyhow::Result { let meta = NestedMeta::parse_meta_list(attr)?; - let ToLayerMessageAttr { - multi, - info_name, - attrs, - } = ToLayerMessageAttr::from_list(&meta)?; + let ToLayerMessageAttr { multi, info_name } = ToLayerMessageAttr::from_list(&meta)?; let is_multi = multi.is_present(); - let attrs = attrs.into_iter().map(|meta| quote!(#[#meta])); let derive_input = syn::parse2::(input)?; + let attrs = &derive_input.attrs; let MessageEnum { vis, ident, @@ -138,9 +132,6 @@ pub fn to_layer_message(attr: TokenStream2, input: TokenStream2) -> manyhow::Res struct ToLayerMessageAttr { multi: Flag, info_name: Option, - - #[darling(default)] - attrs: Punctuated, } #[derive(FromDeriveInput)] From da80fbfee4c7a43c3074be01cbf0c7d998fa28a2 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Fri, 27 Sep 2024 11:52:35 +0900 Subject: [PATCH 6/8] chore: update documents --- iced_layershell/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/iced_layershell/README.md b/iced_layershell/README.md index de8e23b..bbb30fe 100644 --- a/iced_layershell/README.md +++ b/iced_layershell/README.md @@ -58,10 +58,9 @@ enum WindowDirection { // Because new iced delete the custom command, so now we make a macro crate to generate // the Command -#[to_layer_message(attrs = " - derive(Debug, Clone) - | doc = \"Some docs\" -")] +#[to_layer_message] +#[derive(Debug, Clone)] +#[doc = "Some docs"] enum Message { IncrementPressed, DecrementPressed, From 4b53142590f4f4d3d9fc85318adad29200da8a3c Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Fri, 27 Sep 2024 12:02:05 +0900 Subject: [PATCH 7/8] feat: add unit test --- Cargo.lock | 1 + iced_layershell_macros/Cargo.toml | 3 +++ iced_layershell_macros/src/lib.rs | 1 + iced_layershell_macros/tests/macro_test.rs | 12 ++++++++++++ 4 files changed, 17 insertions(+) create mode 100644 iced_layershell_macros/tests/macro_test.rs diff --git a/Cargo.lock b/Cargo.lock index a2311b2..6a2fd9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1829,6 +1829,7 @@ name = "iced_layershell_macros" version = "0.7.1" dependencies = [ "darling", + "iced_layershell", "manyhow", "proc-macro2", "quote", diff --git a/iced_layershell_macros/Cargo.toml b/iced_layershell_macros/Cargo.toml index f82a9b3..15eb68d 100644 --- a/iced_layershell_macros/Cargo.toml +++ b/iced_layershell_macros/Cargo.toml @@ -23,3 +23,6 @@ manyhow = { version = "0.11.4", features = ["darling"] } proc-macro2 = "1.0.86" quote = "1.0.37" syn = { version = "2.0.77", features = ["full"] } + +[dev-dependencies] +iced_layershell.workspace = true diff --git a/iced_layershell_macros/src/lib.rs b/iced_layershell_macros/src/lib.rs index 73f88c5..84b049e 100644 --- a/iced_layershell_macros/src/lib.rs +++ b/iced_layershell_macros/src/lib.rs @@ -142,3 +142,4 @@ struct MessageEnum { generics: Generics, data: Data, } + diff --git a/iced_layershell_macros/tests/macro_test.rs b/iced_layershell_macros/tests/macro_test.rs new file mode 100644 index 0000000..037be1e --- /dev/null +++ b/iced_layershell_macros/tests/macro_test.rs @@ -0,0 +1,12 @@ +use iced_layershell_macros::to_layer_message; + +#[test] +fn test_macro() { + #[to_layer_message] + #[derive(Debug, Clone)] + enum TestEnum { + TestA, + } + let e = TestEnum::SizeChange((10, 10)); + let _ = e.clone(); +} From 501bc9dbc35ddb8cc3628f91a9a9684b9948b56b Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Fri, 27 Sep 2024 12:03:49 +0900 Subject: [PATCH 8/8] chore: fmt --- iced_layershell_macros/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/iced_layershell_macros/src/lib.rs b/iced_layershell_macros/src/lib.rs index 84b049e..73f88c5 100644 --- a/iced_layershell_macros/src/lib.rs +++ b/iced_layershell_macros/src/lib.rs @@ -142,4 +142,3 @@ struct MessageEnum { generics: Generics, data: Data, } -