use super::IndexState;
#[derive(Debug)]
#[must_use = "the entry view provides exclusive access to a stored value"]
pub struct EntryMut<'a, K, O, V> {
pub(crate) key: &'a K,
pub(crate) order: &'a O,
pub(crate) value: &'a mut V,
pub(crate) state: IndexState,
}
impl<'a, K, O, V> EntryMut<'a, K, O, V> {
#[must_use]
#[inline]
pub const fn key(&self) -> &K {
self.key
}
#[must_use]
#[inline]
pub const fn order(&self) -> &O {
self.order
}
#[must_use]
#[inline]
pub const fn value(&self) -> &V {
self.value
}
#[must_use]
#[inline]
pub fn value_mut(&mut self) -> &mut V {
self.value
}
#[must_use]
#[inline]
pub fn into_value_mut(self) -> &'a mut V {
self.value
}
#[must_use = "the attachment state describes ordered visibility"]
#[inline]
pub const fn state(&self) -> IndexState {
self.state
}
#[must_use]
#[inline]
pub const fn is_attached(&self) -> bool {
matches!(self.state, IndexState::Attached)
}
#[must_use]
#[inline]
pub const fn is_detached(&self) -> bool {
matches!(self.state, IndexState::Detached)
}
}