Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propless generic components require generic types to be used #7

Closed
kirillsemyonkin opened this issue Oct 31, 2023 · 1 comment · Fixed by #10
Closed

Propless generic components require generic types to be used #7

kirillsemyonkin opened this issue Oct 31, 2023 · 1 comment · Fixed by #10

Comments

@kirillsemyonkin
Copy link
Collaborator

kirillsemyonkin commented Oct 31, 2023

Imagine a component like so:

#[autoprops_component]
pub fn Example<T: 'static>() -> Html {
    html! {}
}

As T is not used, Rust complains:

parameter `T` is never used
consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
  • Is Properties (generic) struct still generated despite having no props?

At least, currently solvable with following code:

#[autoprops_component]
pub fn Example<T: 'static>(#[prop_or_default] _never: &PhantomData<T>) -> Html {
    html! {}
}
@cecton
Copy link
Member

cecton commented Nov 2, 2023

Fixed in my port of yew-autoprops to Yew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants