Pitasi / rscx

Rust Server Components. JSX-like syntax and async out of the box.
https://rscx.dev/
MIT License
64 stars 6 forks source link

Implement reference props #7

Closed thomaseizinger closed 9 months ago

thomaseizinger commented 1 year ago

This patch allows users to declare parameters as references if they are using the auto-generated props. These parameters would normally need a lifetime but we simply tack one on automatically if it doesn't already have one!

thomaseizinger commented 1 year ago

Just realized this doesn't (yet) work for generic types, like Option<&str> ...

thomaseizinger commented 1 year ago

@Pitasi What do you think of this approach in general?

Pitasi commented 1 year ago

Sorry for late reply @thomaseizinger, I'm taking some time off as I'm getting married next week :)

Anyway, is there a way of letting the users specify their lifetimes? I think it would be better so one can even have multiple lifetimes (or generics?) if needed

thomaseizinger commented 10 months ago

I think it would be better so one can even have multiple lifetimes (or generics?) if needed

Why would you ever need more than one lifetime? Having to write them out is quite tedious. I was hoping that we can avoid that and hide the fact that we are generating a struct in the background as much as possible. In other words, act as if we should just perform lifetime-elision like rustc does for normal functions!