-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
html!: Remove the special for
syntax when rendering iterators
#606
Comments
I've attempted to get started with this, but I'm encountering conflicting implementation errors with the The following code: impl<COMP, T, U> From<T> for VNode<COMP>
where
COMP: Component,
T: IntoIterator<Item = U>,
U: Into<VNode<COMP>>
{
fn from(_: T) -> Self {
unimplemented!()
}
} produces the error:
Without the ability to specify negative traits or use trait specialization, I don't see an immediate way forward without modifying other code. Would removing the [1] https://doc.rust-lang.org/alloc/string/trait.ToString.html#implementors Edit: |
622: Remove special 'for' syntax (WIP) r=jstarry a=hgzimmerman Attempts to address #606 I'm running into coherence issues and conflicting implementations with `ToString` and `IntoIterator` when I try to do a blanket impl for `impl <T: IntoIterator<etc...> From<T> for VNode<COMP>`. If I replace the `ToString` blanket impl with concrete impls for `String` and `&str`, I still run into coherence issues where downstream crates might provide a conflicting impl. I figured that the easiest path forward is to create my own iterator and implement `Into<VNode<COMP>>` for it via an impl for `From`. So this PR thusfar gets us from: #### Before ```rust html! { for self.props.items.iter().map(renderItem) } ``` #### To the start of this PR. ```rust html! { self.props.items.iter().map(renderItem).html() } ``` #### To now ```rust html! { self.props.items.iter().map(renderItem).collect::<Html<Self>>() } ``` Which strictly speaking, is _better_, as it frees up a keyword, but isn't anywhere near what you ideally want: #### Ideal ```rust html! { self.props.items.iter().map(renderItem) } ``` ------- Any feedback on how to achieve this design goal would be appreciated. Co-authored-by: Henry Zimmerman <zimhen7@gmail.com>
From #622
Closing due to Rust limitation |
Problem
It's not intuitive to use a special syntax for rendering iterators, especially when that syntax uses a rust keyword 😝
Proposed
Implement
Into<VNode> for IntoIterator<Into<VNode>>
Before
After
The text was updated successfully, but these errors were encountered: