pub enum StackMapError {
MapFull,
}
Expand description
§StackMap
A fixed-capacity hash map implementation that stores all data on the stack rather than the heap. This provides performance benefits for small maps by eliminating heap allocations and improving cache locality.
§Performance Characteristics
- Optimized for small collections (recommended N ≤ 32)
- Zero heap allocations - everything stays on the stack
- Better cache locality than standard HashMap for small data sets
- O(N) worst-case complexity for operations (acceptable for small N)
- Uses linear probing with deleted flags rather than complex tombstone logic
§Usage Warning
Since all data is stored on the stack, using large capacity values (N > 32) may cause stack overflow in resource-constrained environments. Choose the capacity parameter carefully based on your expected maximum collection size.
§Example
use stackmap::StackMap;
// Create a new map with capacity for 8 entries
let mut map = StackMap::<String, i32, 8>::new();
// Insert some values
map.insert_or_update("one".to_string(), 1).unwrap();
map.insert_or_update("two".to_string(), 2).unwrap();
// Check if a value exists
assert_eq!(map.get(&"one".to_string()), Some(&1));
// Count entries
assert_eq!(map.len(), 2);
Custom error type for StackMap operations
Variants§
MapFull
The map is at full capacity and cannot accept more entries. Consider increasing the capacity template parameter or removing unneeded entries.
Trait Implementations§
Source§impl Clone for StackMapError
impl Clone for StackMapError
Source§fn clone(&self) -> StackMapError
fn clone(&self) -> StackMapError
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for StackMapError
impl Debug for StackMapError
Source§impl PartialEq for StackMapError
impl PartialEq for StackMapError
impl Eq for StackMapError
impl StructuralPartialEq for StackMapError
Auto Trait Implementations§
impl Freeze for StackMapError
impl RefUnwindSafe for StackMapError
impl Send for StackMapError
impl Sync for StackMapError
impl Unpin for StackMapError
impl UnwindSafe for StackMapError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more