|
@@ -17,6 +17,7 @@ pub struct InlinePropsBody {
|
|
pub inputs: Punctuated<FnArg, Token![,]>,
|
|
pub inputs: Punctuated<FnArg, Token![,]>,
|
|
// pub fields: FieldsNamed,
|
|
// pub fields: FieldsNamed,
|
|
pub output: ReturnType,
|
|
pub output: ReturnType,
|
|
|
|
+ pub where_clause: Option<WhereClause>,
|
|
pub block: Box<Block>,
|
|
pub block: Box<Block>,
|
|
}
|
|
}
|
|
|
|
|
|
@@ -28,7 +29,7 @@ impl Parse for InlinePropsBody {
|
|
|
|
|
|
let fn_token = input.parse()?;
|
|
let fn_token = input.parse()?;
|
|
let ident = input.parse()?;
|
|
let ident = input.parse()?;
|
|
- let generics = input.parse()?;
|
|
|
|
|
|
+ let generics: Generics = input.parse()?;
|
|
|
|
|
|
let content;
|
|
let content;
|
|
let paren_token = syn::parenthesized!(content in input);
|
|
let paren_token = syn::parenthesized!(content in input);
|
|
@@ -47,6 +48,11 @@ impl Parse for InlinePropsBody {
|
|
|
|
|
|
let output = input.parse()?;
|
|
let output = input.parse()?;
|
|
|
|
|
|
|
|
+ let where_clause = input
|
|
|
|
+ .peek(syn::token::Where)
|
|
|
|
+ .then(|| input.parse())
|
|
|
|
+ .transpose()?;
|
|
|
|
+
|
|
let block = input.parse()?;
|
|
let block = input.parse()?;
|
|
|
|
|
|
Ok(Self {
|
|
Ok(Self {
|
|
@@ -57,6 +63,7 @@ impl Parse for InlinePropsBody {
|
|
paren_token,
|
|
paren_token,
|
|
inputs,
|
|
inputs,
|
|
output,
|
|
output,
|
|
|
|
+ where_clause,
|
|
block,
|
|
block,
|
|
cx_token,
|
|
cx_token,
|
|
attrs,
|
|
attrs,
|
|
@@ -73,6 +80,7 @@ impl ToTokens for InlinePropsBody {
|
|
generics,
|
|
generics,
|
|
inputs,
|
|
inputs,
|
|
output,
|
|
output,
|
|
|
|
+ where_clause,
|
|
block,
|
|
block,
|
|
cx_token,
|
|
cx_token,
|
|
attrs,
|
|
attrs,
|
|
@@ -136,12 +144,16 @@ impl ToTokens for InlinePropsBody {
|
|
out_tokens.append_all(quote! {
|
|
out_tokens.append_all(quote! {
|
|
#modifiers
|
|
#modifiers
|
|
#[allow(non_camel_case_types)]
|
|
#[allow(non_camel_case_types)]
|
|
- #vis struct #struct_name #struct_generics {
|
|
|
|
|
|
+ #vis struct #struct_name #struct_generics
|
|
|
|
+ #where_clause
|
|
|
|
+ {
|
|
#(#fields),*
|
|
#(#fields),*
|
|
}
|
|
}
|
|
|
|
|
|
#(#attrs)*
|
|
#(#attrs)*
|
|
- #vis fn #ident #fn_generics (#cx_token: Scope<#scope_lifetime #struct_name #generics>) #output {
|
|
|
|
|
|
+ #vis fn #ident #fn_generics (#cx_token: Scope<#scope_lifetime #struct_name #generics>) #output
|
|
|
|
+ #where_clause
|
|
|
|
+ {
|
|
let #struct_name { #(#field_names),* } = &cx.props;
|
|
let #struct_name { #(#field_names),* } = &cx.props;
|
|
#block
|
|
#block
|
|
}
|
|
}
|