From 2f1f2b33957276c1cc60483010729d353d733bc3 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 23 Dec 2024 01:37:37 +0100 Subject: [PATCH] some changes --- Cargo.toml | 6 +----- lib.rs | 28 ++-------------------------- main.rs | 14 -------------- 3 files changed, 3 insertions(+), 45 deletions(-) delete mode 100644 main.rs diff --git a/Cargo.toml b/Cargo.toml index ca6d92c..c6d718e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "osui-element" -version = "0.1.16" +version = "0.1.17" edition = "2021" description = "The element attribute for defining elements in OSUI" license = "Apache-2.0" @@ -9,10 +9,6 @@ license = "Apache-2.0" proc-macro = true path = "./lib.rs" -[[bin]] -name = "osui-element" -path = "./main.rs" - [dependencies] proc-macro2 = "1.0.89" quote = "1.0" diff --git a/lib.rs b/lib.rs index 765f8f8..cb43cb8 100644 --- a/lib.rs +++ b/lib.rs @@ -1,8 +1,8 @@ use proc_macro::TokenStream; use quote::quote; use syn::{ - parse::Parser, parse_macro_input, DeriveInput, Fields, GenericParam, ItemFn, Lifetime, - LifetimeParam, + parse::Parser, parse_macro_input, DeriveInput, Fields, GenericParam, ItemFn, + Lifetime, LifetimeParam, }; #[proc_macro_attribute] @@ -90,30 +90,6 @@ pub fn element(_args: TokenStream, input: TokenStream) -> TokenStream { expanded.into() } -#[proc_macro_attribute] -pub fn elem_fn(_args: TokenStream, input: TokenStream) -> TokenStream { - let ast = parse_macro_input!(input as DeriveInput); - let struct_name = &ast.ident; - - let func_name = syn::Ident::new( - &struct_name.to_string().to_lowercase(), - proc_macro2::Span::call_site(), - ); - - let elem_fn = quote! { - pub fn #func_name<'a>() -> Box<#struct_name<'a>> { - Box::new(#struct_name::default()) - } - }; - - let expanded = quote! { - #ast - #elem_fn - }; - - expanded.into() -} - #[proc_macro_attribute] pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream { let input_fn = parse_macro_input!(input as ItemFn); diff --git a/main.rs b/main.rs deleted file mode 100644 index d8bd868..0000000 --- a/main.rs +++ /dev/null @@ -1,14 +0,0 @@ -use osui_element::component; - -type Element = i32; - -pub trait Component: std::fmt::Debug { - fn create_element(&self) -> Element; -} - -#[component] -fn testing() { - 20 -} - -fn main() {}