sycamore icon indicating copy to clipboard operation
sycamore copied to clipboard

Support `impl Trait` syntax with `inline_props`

Open lukechu10 opened this issue 3 years ago • 0 comments

Right now, inline_props does not support the impl Trait syntax which is often useful to prevent adding tons of generics to a function.

We would like the following syntax to work out of the box:

#[component(inline_props]
fn MyComponent<G: Html>(cx: Scope, foo: impl MyTrait) -> View<G> {
    ...
} 

The difficulty with this is that we cannot directly translate impl MyTrait into a struct field because this syntax is only supported for functions. We therefore need to manually transform the impl MyTrait into an explicit generic parameter in the generated struct.

lukechu10 avatar Oct 16 '22 21:10 lukechu10