From f6cf2be0ed27c6baa55060b24bd228006f8c4ee3 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 23 Dec 2024 12:44:48 +0100 Subject: [PATCH] Fixed a few things --- Cargo.toml | 2 +- lib.rs | 5 +++-- main.rs | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dbda4ad..fccd5a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "osui-element" -version = "0.1.22" +version = "0.1.23" edition = "2021" description = "The element attribute for defining elements in OSUI" license = "Apache-2.0" diff --git a/lib.rs b/lib.rs index 14ff449..851ad88 100644 --- a/lib.rs +++ b/lib.rs @@ -90,7 +90,7 @@ pub fn element(_args: TokenStream, input: TokenStream) -> TokenStream { } #[proc_macro_attribute] -pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream { +pub fn component(_: TokenStream, input: TokenStream) -> TokenStream { let input_fn = parse_macro_input!(input as ItemFn); let fn_name = input_fn.sig.ident.clone(); @@ -135,7 +135,8 @@ pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream { } impl <#(#lifetimes),*> Component for #fn_name <#(#lifetimes),*> { - fn create_element(self) -> #return_type { + type Element = #return_type; + fn create_element(self) -> Self::Element { #code } } diff --git a/main.rs b/main.rs index 061fdff..eece5d6 100644 --- a/main.rs +++ b/main.rs @@ -2,8 +2,9 @@ use osui_element::component; pub type Element = i32; -pub trait Component { - fn create_element(self) -> Element; +pub trait Component: std::fmt::Debug { + type Element; + fn create_element(self) -> Self::Element; } #[component]