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
compile_error!;
pub
pub use *;
pub use *;
/// An untyped allocator that provides mutable slices of uninitialised memory.
///
/// Types implementing this trait can serve as the backing store for
/// [`TypedArena`], which adds automatic destructor execution and
/// type‑safe allocation on top of the raw memory.
///
/// # Safety
///
/// Implementors must uphold the following invariants. Violating any of them
/// will cause **undefined behaviour** in safe code that uses [`TypedArena`].
///
/// - **Alignment** -- every slice returned by [`UninitAllocator::try_alloc_uninit`] is aligned
/// to at least the requested `layout.align()`.
/// - **No overlap** -- the memory regions handed out never overlap. For
/// example, a bump allocator achieves this by monotonically advancing a
/// pointer; other strategies are possible as long as they guarantee
/// disjointness.
/// - **Stable addresses** -- the memory backing a returned slice remains valid
/// and at the same address until the allocator is dropped or explicitly
/// reset. The allocator must never invalidate previously‑returned pointers
/// while they may still be in use.
/// - **Single‑threaded confinement** -- the allocator is designed for
/// single‑threaded use. Even if the type implements `Sync`, the user
/// **must not** share a reference to the allocator across threads. Doing
/// so can cause data races on the allocator’s internal state and lead to
/// undefined behaviour.
pub unsafe