mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Fix defaulted type parameter. (#2284)
* Fix defaulted type parameter. * Add test.
This commit is contained in:
parent
f5b921984a
commit
5b0bbd55c9
@ -192,7 +192,7 @@ pub fn function_component_impl(
|
||||
#[doc(hidden)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(unused_parens)]
|
||||
#vis struct #function_name #impl_generics {
|
||||
#vis struct #function_name #generics {
|
||||
_marker: ::std::marker::PhantomData<(#phantom_generics)>,
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ pub fn function_component_impl(
|
||||
|
||||
#(#attrs)*
|
||||
#[allow(type_alias_bounds)]
|
||||
#vis type #component_name #impl_generics = ::yew::functional::FunctionComponent<#function_name #ty_generics>;
|
||||
#vis type #component_name #generics = ::yew::functional::FunctionComponent<#function_name #ty_generics>;
|
||||
};
|
||||
|
||||
Ok(quoted)
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
use yew::prelude::*;
|
||||
|
||||
#[derive(Properties, Debug)]
|
||||
pub struct CompProps<A> {
|
||||
#[prop_or_default]
|
||||
_phantom: std::marker::PhantomData<A>,
|
||||
}
|
||||
|
||||
impl<A> PartialEq for CompProps<A> {
|
||||
fn eq(&self, _rhs: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[function_component(Comp)]
|
||||
pub fn comp<A = ()>(_props: &CompProps<A>) -> Html {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[function_component(App)]
|
||||
pub fn app() -> Html {
|
||||
html! { <Comp /> } // No generics here.
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
x
Reference in New Issue
Block a user