1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use Hash;
/// Describes how items in a reactive list are identified.
///
/// Implement this on a zero-sized **marker type** (not on the item itself). The
/// marker is the generic parameter threaded through the keyed-collection
/// machinery: [`render_list_memo`](crate::render::render_list_memo),
/// [`render_resource_list_memo`](crate::render::render_resource_list_memo) (via
/// [`keyed_computed_list`](crate::keyed_computed_list)) and
/// [`LazyListCache`](crate::LazyListCache).
///
/// The associated [`Key`](CollectionKey::Key) gives each item a stable identity.
/// This is what enables per-item **memoization** (an item keeps the same inner
/// reactive cell across list updates as long as its key is stable, so only items
/// whose content actually changed are re-rendered) and **deduplication**
/// (items sharing a key within one list are reported and skipped).
///
/// ```rust
/// use vertigo::CollectionKey;
///
/// #[derive(Clone, PartialEq, Eq, Debug)]
/// struct Item { id: u32, name: String }
///
/// struct ItemKey; // marker type
///
/// impl CollectionKey for ItemKey {
/// type Key = u32;
/// type Value = Item;
/// fn get_key(val: &Item) -> u32 { val.id }
/// }
/// ```