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
use *;
/// Obtains the [`UseId`] registered against the current hook context slot.
///
/// Behaves like `HookContext::use_hook` - the same `UseId` is returned on
/// every render at the same hook index, so the generated identifier is
/// stable across re-renders and stable across the element's lifetime.
///
/// The identifier is produced by a process-wide counter, so two
/// components in the same page never share one.
///
/// # Arguments
///
/// - `&'static str` - The prefix put in front of the counter, for
/// example `"field"`.
///
/// # Returns
///
/// - `UseId` - The identifier handle, with `get_value()` returning the
/// generated string.
/// Hands out the next process-wide identifier number.
///
/// The counter is a plain atomic: the value only has to be unique, and
/// two threads racing for the same number would still produce two
/// different identifiers because the increment is atomic.
///
/// # Returns
///
/// - `usize` - The next identifier number.