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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Off-feature type aliases — symmetry with the `tracked` module so that
//! consumer code can refer to `TrackedVec<T>` etc. in BOTH feature modes
//! and the source is identical.
//!
//! # Design decision
//!
//! In on-feature mode `TrackedVec<T>` is a `pub struct` defined in
//! `tracked::vec`. Here, off-feature, it is `pub type TrackedVec<T> = Vec<T>`
//! — same identifier, same surface.
//!
//! ## Optional dependencies
//!
//! The standard-library types (`Vec`, `VecDeque`, `BTreeMap`, `BTreeSet`,
//! `HashMap`, `HashSet`) are always available.
//!
//! The optional third-party types (`bytes::BytesMut`, `indexmap::IndexMap`,
//! `indexmap::IndexSet`, `dashmap::DashMap`, `scc::HashMap`, `scc::HashSet`,
//! `scc::TreeIndex`) require the consumer to add those crates as *direct*
//! dependencies. To advertise which aliases are available, captrack exposes
//! mirror feature flags that only pull in the dep (no telemetry overhead):
//!
//! * `bytes` → `TrackedBytesMut`
//! * `indexmap` → `TrackedIndexMap`, `TrackedIndexSet`
//! * `dashmap` → `TrackedDashMap`
//! * `scc` → `TrackedSccHashMap`, `TrackedSccHashSet`, `TrackedSccTreeIndex`
//!
//! A consumer wishing to use `TrackedBytesMut` off-feature adds
//! `captrack = { features = ["bytes"] }` (no `telemetry`).
//!
//! When `telemetry` IS active these aliases are never compiled — the real
//! `TrackedX` structs from `tracked::` win.
//!
//! ## Hasher default consistency
//!
//! Aliases for hash types (`HashMap`, `HashSet`, `IndexMap`, `IndexSet`,
//! `DashMap`, `scc::HashMap`, `scc::HashSet`) default `S = CapHasher`. This
//! matches the on-feature `Tracked*` struct defaults, keeping the type
//! signatures identical across both modes.
//!
//! Without any hasher feature, `CapHasher == RandomState` and the alias is
//! identical to `std::HashMap<K, V>` etc.
//!
//! **Caveat**: when the consumer enables `fxhash` / `ahash` / `foldhash` /
//! `rustc-hash`, `CapHasher` changes to the fast hasher and the alias
//! silently changes its default `S` relative to a hand-written bare
//! `std::HashMap<K, V>` (which always uses `RandomState`). Mixing the alias
//! with bare collections in the same scope then needs explicit type
//! annotations such as `let m: HashMap<_, _, _> = ...` to disambiguate the
//! hasher parameter.
// mirroring std/third-party types is the whole point
// ── Always-available std types ───────────────────────────────────────────────
pub type TrackedVec<T> = Vec;
pub type TrackedVecDeque<T> = VecDeque;
pub type TrackedBTreeMap<K, V> = BTreeMap;
pub type TrackedBTreeSet<T> = BTreeSet;
pub type TrackedHashMap<K, V, S = crateCapHasher> = HashMap;
pub type TrackedHashSet<T, S = crateCapHasher> = HashSet;
pub type TrackedString = String;
pub type TrackedBinaryHeap<T> = BinaryHeap;
// ── Optional third-party types ───────────────────────────────────────────────
//
// Each alias is gated on the corresponding standalone feature flag.
// The `telemetry` feature also activates these deps, but this file is
// only compiled in `not(feature = "telemetry")` mode — so there is no
// overlap risk.
pub type TrackedBytesMut = BytesMut;
pub type TrackedIndexMap<K, V, S = crateCapHasher> = IndexMap;
pub type TrackedIndexSet<T, S = crateCapHasher> = IndexSet;
pub type TrackedDashMap<K, V, S = crateCapHasher> = DashMap;
pub type TrackedSccHashMap<K, V, S = crateCapHasher> = HashMap;
pub type TrackedSccHashSet<T, S = crateCapHasher> = HashSet;
pub type TrackedSccTreeIndex<K, V> = TreeIndex;
pub type TrackedSmallVec<A> = SmallVec;
pub type TrackedHashbrownMap<K, V, S = DefaultHashBuilder> =
HashMap;