fix: Support Input::<..> style to for generic components

before that, we accepted this style `Input<..>` but to be consistent
with Rust syntax this is dropped now.

> For reference, the two ways of specifying explicit type parameters in
> Rust are:
> // for functions
> let _ = foo::<MyType>();
>
> // for structs
> let _ = Foo::<MyType> { ... };
>
> by @jkelleyrtp
This commit is contained in:
Muhannad Alrusayni 2022-05-07 06:47:16 +03:00
parent 5b079075d7
commit 690efade88
2 changed files with 4 additions and 4 deletions

View file

@ -141,7 +141,7 @@ impl ToTokens for Component {
}
None => {
let mut toks = match prop_gen_args {
Some(gen_args) => quote! { fc_to_builder::#gen_args(#name) },
Some(gen_args) => quote! { fc_to_builder #gen_args(#name) },
None => quote! { fc_to_builder(#name) },
};
for field in &self.body {

View file

@ -65,10 +65,10 @@ impl Parse for BodyNode {
// ::component ()
// crate::component{}
// crate::component()
// Input<'_, String> {}
// crate::Input<'_, i32> {}
// Input::<InputProps<'_, i32> {}
// crate::Input::<InputProps<'_, i32> {}
if body_stream.peek(token::Brace) || body_stream.peek(token::Paren) {
// this syntax is not allowd:
// NOTE: this syntax is not allowd:
// Div () -> comp
if path.segments.len() == 1 && body_stream.peek(token::Paren) {
let com_ident = &path.segments.iter().next().unwrap().ident;