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
//! Safe bump-pointer arena allocator.
//!
//! `safe-bump` provides two typed arena allocators built entirely with safe
//! Rust (zero `unsafe` blocks). Values are allocated and accessed via stable
//! [`Idx<T>`] indices.
//!
//! # Arena types
//!
//! - [`Arena<T>`] — single-thread, zero overhead, backed by [`Vec<T>`]
//! - [`SharedArena<T>`] — thread-safe (`Send + Sync`), wait-free reads,
//! concurrent allocation via `&self`
//!
//! Both types share the same [`Idx<T>`] and [`Checkpoint<T>`] types, support
//! checkpoint/rollback, and run destructors on rollback/reset/drop.
//!
//! # Key properties
//!
//! - **Zero `unsafe`**: enforced by `#![forbid(unsafe_code)]`
//! - **Auto [`Drop`]**: destructors run on reset, rollback, and arena drop
//! - **Checkpoint/rollback**: save state and discard speculative allocations
//! - **Thread-safe**: [`SharedArena<T>`] supports concurrent allocation
//!
//! # Example
//!
//! ```
//! use safe_bump::{Arena, Idx};
//!
//! let mut arena: Arena<String> = Arena::new();
//! let a: Idx<String> = arena.alloc(String::from("hello"));
//! let b: Idx<String> = arena.alloc(String::from("world"));
//!
//! assert_eq!(arena[a], "hello");
//! assert_eq!(arena[b], "world");
//!
//! let cp = arena.checkpoint();
//! let _tmp = arena.alloc(String::from("temporary"));
//! arena.rollback(cp); // "temporary" is dropped
//! assert_eq!(arena.len(), 2);
//! ```
//!
//! # References
//!
//! - Hanson, 1990 — "Fast Allocation and Deallocation of Memory
//! Based on Object Lifetimes"
pub use Arena;
pub use Checkpoint;
pub use Idx;
pub use ;
pub use ;