pub struct IdMap { /* private fields */ }Implementations§
Source§impl IdMap
impl IdMap
pub fn new() -> Self
pub fn get_or_insert(&mut self, key: &str) -> u32
Sourcepub fn try_insert(&mut self, key: &str) -> Result<u32>
pub fn try_insert(&mut self, key: &str) -> Result<u32>
Allocate a dense id for key, or return the existing live id.
Fails before wrap when the next id would not fit in u32.
pub fn get(&self, key: &str) -> Option<u32>
pub fn key_of(&self, id: u32) -> Option<&str>
Sourcepub fn delete(&mut self, key: &str) -> Option<u32>
pub fn delete(&mut self, key: &str) -> Option<u32>
Remove key from the live map, permanently tombstone its dense id, and
return that id. Returns None if the key is not present.
Sourcepub fn is_tombstoned(&self, id: u32) -> bool
pub fn is_tombstoned(&self, id: u32) -> bool
Returns true if id has been retired by a prior delete call.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of total id slots ever allocated (live + tombstoned). Stable across
deletes and re-inserts — use live_len for the live count.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IdMap
impl<'de> Deserialize<'de> for IdMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for IdMap
impl RefUnwindSafe for IdMap
impl Send for IdMap
impl Sync for IdMap
impl Unpin for IdMap
impl UnsafeUnpin for IdMap
impl UnwindSafe for IdMap
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