#![doc = include_str!("../README.md")]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
mod arena;
pub mod linked_hash_map;
extern crate alloc;
#[cfg(feature = "std")]
type RandomState = std::hash::RandomState;
#[cfg(not(feature = "std"))]
type RandomState = hashbrown::DefaultHashBuilder;
pub type LinkedHashMap<K, V> = crate::linked_hash_map::LinkedHashMap<K, V, RandomState>;
use core::num::NonZeroU32;
pub use linked_hash_map::CursorMut;
pub use linked_hash_map::Entry;
pub use linked_hash_map::IntoIter;
pub use linked_hash_map::Iter;
pub use linked_hash_map::OccupiedEntry;
pub use linked_hash_map::VacantEntry;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct Ptr(NonZeroU32);
impl core::fmt::Debug for Ptr {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Ptr({})", self.0.get() - 1)
}
}
impl Ptr {
pub(crate) fn unchecked_from(index: usize) -> Self {
debug_assert!(
index < u32::MAX as usize,
"Index too large to fit in Ptr: {index}"
);
Ptr(NonZeroU32::new((index as u32).saturating_add(1)).unwrap())
}
pub(crate) fn unchecked_get(self) -> usize {
self.0.get() as usize - 1
}
}