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
40
41
42
43
44
45
use *;
/// Obtains the previous-value tracker registered against the current
/// hook context slot.
///
/// Behaves like `HookContext::use_hook`: the same `Previous` is
/// returned on every render at the same hook index, so the captured
/// `previous` signal survives across renders without losing state.
///
/// # Returns
///
/// - `Previous<T>` - The previous-value tracker handle.
/// Returns the factory result directly when no hook context is
/// active (e.g. when called outside a render cycle).
/// Records `current` against the supplied tracker and returns the
/// snapshot of what was previously recorded.
///
/// Convenience wrapper used by component-level consumers that want
/// the "compute previous" + "record new current" steps glued together.
/// Returns `None` on the first call (no prior value exists yet).
///
/// # Arguments
///
/// - `Previous<T>` - The tracker obtained from `use_previous()`.
/// - `T` - The current value to record.
///
/// # Returns
///
/// - `Option<T>` - The value that was recorded on the previous call,
/// or `None` if no prior value exists.