From 2d0668955e7d45ddc32d9cf7658be2413b3bd2bf Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 23 Dec 2024 00:28:14 +0100 Subject: [PATCH] updated component --- Cargo.toml | 2 +- lib.rs | 6 +++--- main.rs | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 607b673..ca6d92c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "osui-element" -version = "0.1.15" +version = "0.1.16" edition = "2021" description = "The element attribute for defining elements in OSUI" license = "Apache-2.0" diff --git a/lib.rs b/lib.rs index e5103c1..765f8f8 100644 --- a/lib.rs +++ b/lib.rs @@ -141,14 +141,14 @@ pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream { }); let expanded = quote! { - #[derive(Debug)] + #[derive(Debug, Default)] #[allow(non_camel_case_types)] #visibility struct #fn_name { #(#struct_fields),* } - impl #fn_name { - pub fn create_element(&self) -> #return_type { + impl Component for #fn_name { + fn create_element(&self) -> #return_type { #code } } diff --git a/main.rs b/main.rs index f328e4d..d8bd868 100644 --- a/main.rs +++ b/main.rs @@ -1 +1,14 @@ +use osui_element::component; + +type Element = i32; + +pub trait Component: std::fmt::Debug { + fn create_element(&self) -> Element; +} + +#[component] +fn testing() { + 20 +} + fn main() {}