Skip to content

Propless generic components require generic types to be used #7

@kirillsemyonkin

Description

@kirillsemyonkin

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! {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions