# for_each

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view/prelude/function-for_each/

**function** · [`ferroui-view`](/docs/0.5.0/api/ferroui-view/) · v0.5.0

```rust
fn for_each<T, I, K, E>(each: impl Fn() -> I + 'static, key: impl Fn(&T) -> K + 'static, view: impl Fn(T) -> E + 'static) -> crate::element::Element
where I: IntoIterator<Item = T>,
      T: Clone + PartialEq + 'static,
      K: Into<crate::element::Key>,
      E: IntoElement
```

A list of children made from items, one per item, kept by key: an item
whose key and value stay keeps its control; an item that is new or whose
value changed gets a new one; the controls of items that left are taken
out. `each` is reactive: the list follows the signals it reads.

```ignore
for_each(move || todos.get(), |todo| todo.id, move |todo| text_block().text(todo.title))
```

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/control_flow.rs#L23)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
