Fix: quick tweak to allow #[component] macro working
This commit is contained in:
2 files changed
+7
-10
No files matched your search
@@ -47,7 +47,7 @@ fn get_props_struct(component_body: &ComponentBody) -> ItemStruct {
|
||||
} = sig;
|
||||
|
||||
// Skip first arg since that's the context
|
||||
let struct_fields = inputs.iter().skip(1).map(move |f| {
|
||||
let struct_fields = inputs.iter().skip(0).map(move |f| {
|
||||
match f {
|
||||
FnArg::Receiver(_) => unreachable!(), // Unreachable because of ComponentBody parsing
|
||||
FnArg::Typed(pt) => {
|
||||
@@ -74,9 +74,9 @@ fn get_props_struct(component_body: &ComponentBody) -> ItemStruct {
|
||||
};
|
||||
|
||||
let struct_attrs = if first_lifetime.is_some() {
|
||||
quote! { #[derive(Props)] }
|
||||
quote! { #[derive(Props, Clone)] }
|
||||
} else {
|
||||
quote! { #[derive(Props, PartialEq)] }
|
||||
quote! { #[derive(Props, Clone, PartialEq)] }
|
||||
};
|
||||
|
||||
let struct_generics = if first_lifetime.is_some() {
|
||||
@@ -245,7 +245,7 @@ fn get_function(component_body: &ComponentBody) -> ItemFn {
|
||||
let struct_ident = Ident::new(&format!("{fn_ident}Props"), fn_ident.span());
|
||||
|
||||
// Skip first arg since that's the context
|
||||
let struct_field_names = inputs.iter().skip(1).filter_map(|f| match f {
|
||||
let struct_field_names = inputs.iter().skip(0).filter_map(|f| match f {
|
||||
FnArg::Receiver(_) => unreachable!(), // ComponentBody prohibits receiver parameters.
|
||||
FnArg::Typed(pt) => Some(&pt.pat),
|
||||
});
|
||||
@@ -296,7 +296,7 @@ fn get_function(component_body: &ComponentBody) -> ItemFn {
|
||||
#asyncness #vis fn #fn_ident #fn_generics (__props: #struct_ident #generics_no_bounds) #fn_output
|
||||
#where_clause
|
||||
{
|
||||
let #struct_ident { #(#struct_field_names),* } = &__props;
|
||||
let #struct_ident { #(#struct_field_names),* } = __props;
|
||||
#fn_block
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,8 @@ pub fn derive_typed_builder(input: TokenStream) -> TokenStream {
|
||||
|
||||
/// The rsx! macro makes it easy for developers to write jsx-style markup in their components.
|
||||
#[proc_macro]
|
||||
pub fn rsx(s: TokenStream) -> TokenStream {
|
||||
match syn::parse::<rsx::CallBody>(s) {
|
||||
Err(err) => err.to_compile_error().into(),
|
||||
Ok(body) => body.to_token_stream().into(),
|
||||
}
|
||||
pub fn rsx(tokens: TokenStream) -> TokenStream {
|
||||
render(tokens)
|
||||
}
|
||||
|
||||
/// The render! macro makes it easy for developers to write jsx-style markup in their components.
|
||||
|
||||
Reference in new issue
Block a user