xilem
xilem copied to clipboard
Add #[derive(View)] for enums and nested structs
I think a derive
macro for the view trait, especially on enums, would really benefit ergonomics.
Views that return multiple types on a condition, such as an if
block or match
statement, could instead return an enum with View
derived.
For example, for conditional views we could return a custom enum like:
#[derive(View)]
enum UserForm {
Login(LoginView),
SignUp(SignUpView)
}
Sorry for the slow response.
I like the idea to derive View
for enums but am not so sure about structs. We already have implemented ViewSequence
for Tuples. I don't see the benefit of implementing this for other product types.
The other thing to consider is that we already have AnyView
which can do the same thing. And since this would be more of a performance improvement for platforms like embedded, it not a priority right now.