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
// Copyright Two Neutron Stars Incorporated and contributors
// SPDX-License-Identifier: BlueOak-1.0.0
//! Heterogeneous list (HList) primitives.
//!
//! This module provides generic HList building blocks - a type-safe way to store
//! heterogeneous collections where each element can have a different type.
//!
//! # Architecture
//!
//! An HList is a nested structure of `HCons` cells terminated by `HNil`:
//!
//! ```text
//! HCons<A, HCons<B, HCons<C, HNil>>>
//! ```
//!
//! Type-level indices (`Here`, `There<There<Here>>`) allow accessing specific
//! positions in the list at compile time, with no runtime overhead.
//!
//! # Usage
//!
//! Typically used via the [`define_partitions!`](crate::define_partitions) macro
//! which builds HLists of `PartitionStore`s. See [`partition_store`](super::partition_store)
//! for partition-specific HList traits.
use PhantomData;
/// The empty HList, used as the terminator for all HList chains.
///
/// `HNil` marks the end of an HList. Every HList ends with `HNil`:
///
/// ```text
/// HCons<A, HCons<B, HNil>>
/// ^^^^
/// ```
;
/// A cons cell in an HList, holding a head element and a tail.
///
/// `HCons` is the building block for heterogeneous lists. Each cell holds:
/// - `head`: The current element
/// - `tail`: The rest of the list (another `HCons` or `HNil`)
///
/// # Type Parameters
///
/// - `H`: The type of the head element
/// - `T`: The type of the tail (must be another HList type)
/// Type-level index indicating the current (head) position in an HList.
///
/// Used for compile-time indexing into HLists. For deeper positions, wrap with [`There`].
///
/// # Example
///
/// ```text
/// Here -> position 0 (head)
/// There<Here> -> position 1
/// There<There<Here>> -> position 2
/// ```
;
/// Type-level index indicating a position deeper in the HList.
///
/// `There<Idx>` means "skip the head and look at position `Idx` in the tail".
/// Combined with [`Here`], these types form compile-time natural numbers.
///
/// # Type Parameters
///
/// - `T`: The index within the tail (either `Here` or another `There<...>`)
;
// SAFETY: HNil contains no data, so it's trivially Send and Sync.
unsafe
unsafe
// SAFETY: HCons is Send/Sync if both its head and tail are Send/Sync.
unsafe
unsafe