#4073·yew

`for x in children.iter()` works in `html!` but `for x in &children` does not

Author: MadoshakalakaCreated Mar 18, 2026Updated Aug 29, 2026

Problem

The for loop syntax in html! requires children.iter() to compile, but does not accept &children, which is the idiomatic Rust form and what clippy's explicit_iter_loop lint likes.

Minimal Reproduction

This compiles:

rust
#[derive(Clone, PartialEq, Properties)]
pub struct WrapperProps {
    pub children: Children,
}

#[component]
fn Wrapper(props: &WrapperProps) -> Html {
    html! {
        <ul>
            for child in props.children.iter() {
                <li>{child}</li>
            }
        </ul>
    }
}

This does not:

rust
#[component]
fn Wrapper(props: &WrapperProps) -> Html {
    html! {
        <ul>
            for child in &props.children {
                <li>{child}</li>
            }
        </ul>
    }
}

Expected behavior both should compile

Environment:

  • Yew version: [0.23.0]

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later