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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//! A high-performance vector crate tuned for small data sizes.
//!
//! Uses small-buffer optimization (SBO): data is stored in an inline buffer first,
//! then moved to heap storage when capacity is exceeded.
//!
//! ## Container Guide
//!
//! We provide three containers for different scenarios:
//!
//! | Container | Storage | Best for |
//! |-----------|---------|----------|
//! | **[ArrayVec]** | Inline-only, fixed capacity | When you need peak performance and know the max element count |
//! | **[FastVec]** | Inline first, auto-switch to heap | When you need peak performance for temporary data |
//! | **[SmallVec]** | Inline first, auto-switch to heap | When you need long-term storage with an unknown but typically small element count |
//!
//! If you have many elements and need long-term storage, consider using [`Vec`](alloc::vec::Vec) directly.
//!
//! ### [ArrayVec]
//!
//! An inline-only `Vec` that allocates space without initializing data.
//!
//! **Features:**
//! - No extra heap allocations
//! - Extreme array-like performance
//! - Vec-compatible API
//! - Compile-time fixed capacity, cannot grow
//!
//! A great replacement for a plain array `[T; N]`.
//!
//! ```rust, ignore
//! # use fastvec::ArrayVec;
//! let mut vec: ArrayVec<i32, 10> = ArrayVec::new();
//!
//! vec.push(1);
//! vec.push(2);
//!
//! assert_eq!(vec, [1, 2]);
//! assert_eq!(vec.len(), 2);
//! assert_eq!(vec.capacity(), 10); // Fixed capacity
//! ```
//!
//! Supports nearly all [`Vec`](alloc::vec::Vec) operations (except reallocation).
//!
//! See the [`ArrayVec`] docs for details.
//!
//! ### [FastVec]
//!
//! A `Vec` for temporary data that auto-grows. It prefers inline storage and switches
//! to the heap when capacity is insufficient.
//!
//! **Features:**
//! - `!Sync`, generally for temporary data processing
//! - Supports capacity growth
//! - Inline-first; no heap allocs for small sizes
//! - Guaranteed not slower than `Vec` for large sizes
//!
//! This container caches pointers to minimize inline/heap checks, keeping performance
//! from degrading (even on the heap it’s no slower than `Vec`) and outperforming [`SmallVec`].
//!
//! ```rust, ignore
//! # use fastvec::FastVec;
//! let mut vec: FastVec<i32, 5> = [1, 2, 3].into();
//! assert_eq!(vec.capacity(), 5);
//!
//! // Auto-grows; switches to heap when needed
//! vec.data().extend([4, 5, 6, 7, 8]);
//! assert_eq!(vec, [1, 2, 3, 4, 5, 6, 7, 8])
//! ```
//!
//! Pointer caching introduces self-references, so it is `!Sync`. Any data access must
//! first call [`FastVec::data`] to obtain the correct [`FastVecData`] reference.
//!
//! `data` incurs one branch and pointer assignment; typically you should grab the data
//! reference once, use it via references, and only switch when you need to move the data.
//!
//! See the [`FastVec`] docs for details.
//!
//! ### [SmallVec]
//!
//! A space-optimized SBO `Vec`.
//!
//! **Features:**
//! - `Sync + Send`, suitable for long-term storage
//! - Supports capacity growth
//! - Inline-first; no heap allocs for small sizes
//! - Vec-compatible API
//!
//! Unlike [`FastVec`], this container checks inline/heap location on operations
//! and is designed similarly to [`smallvec::SmallVec`](https://docs.rs/smallvec/latest/smallvec).
//!
//! It is efficient for small data but may lag `Vec` on large data,
//! especially on simple functions like data access and `push/pop`.
//!
//! ```rust, ignore
//! # use fastvec::SmallVec;
//! let mut vec: SmallVec<i32, 5> = [1, 2, 3].into();
//! assert_eq!(vec.capacity(), 5);
//!
//! // Auto-grows; switches to heap when needed
//! vec.extend([4, 5, 6, 7, 8]);
//! assert_eq!(vec, [1, 2, 3, 4, 5, 6, 7, 8])
//! ```
//!
//! Supports all [`Vec`](alloc::vec::Vec) operations without needing `data()`.
//!
//! See the [`SmallVec`] docs for details.
//!
//! ## no_std Support
//!
//! FastVec depends only on `core` and `alloc` by default,
//! making it ideal for embedded and no_std environments.
//!
//! ## Optional Features
//!
//! ### arrayvec
//!
//! Enabled by default. If disabled, `ArrayVec` code is not compiled.
//!
//! ### fastvec
//!
//! Enabled by default. If disabled, `FastVec` code is not compiled.
//!
//! ### smallvec
//!
//! Enabled by default. If disabled, `SmallVec` code is not compiled.
//!
//! ### serde
//!
//! When enabled, `ArrayVec`, `FastVec` and `SmallVec` implement
//! `serde::Serialize` and `serde::Deserialize` .
//!
//! ### std
//!
//! When enabled, `ArrayVec`, `FastVec` and `SmallVec` implement `std::io::Write` .
extern crate alloc;
pub use ;
pub use ArrayVec;
pub use SmallVec;