Skip to main content

key

Function key 

Source
pub fn key<K: Hash, R>(key: K, content: impl FnOnce() -> R) -> R
Expand description

Gives content an identity of its own, made from key rather than from its position. Compose’s key.

In a loop over items that can move, each iteration’s state belongs to whichever item it was composed for, and a reordered item’s node is moved rather than rebuilt:

ⓘ
for task in tasks.iter() {
    key(task.id, || TaskRow(task.clone()));
}