pub enum Entry<'a, K: Ord + Clone + Sized, V: Sized> {
Occupied(OccupiedEntry<'a, K, V>),
Vacant(VacantEntry<'a, K, V>),
}Available on crate feature
btree only.Expand description
Entry into a BTreeMap for in-place manipulation
Variants§
Occupied(OccupiedEntry<'a, K, V>)
Vacant(VacantEntry<'a, K, V>)
Implementations§
Source§impl<'a, K: Ord + Clone + Sized, V: Sized> Entry<'a, K, V>
impl<'a, K: Ord + Clone + Sized, V: Sized> Entry<'a, K, V>
pub fn exists(&self) -> bool
Sourcepub fn or_insert(self, default: V) -> &'a mut Vwhere
K: Ord,
pub fn or_insert(self, default: V) -> &'a mut Vwhere
K: Ord,
Ensures a value is in the entry by inserting the default if empty, and returns a mutable reference to the value in the entry.
Sourcepub fn or_insert_with<F>(self, default: F) -> &'a mut V
pub fn or_insert_with<F>(self, default: F) -> &'a mut V
Ensures a value is in the entry by inserting the result of the default function if empty, and returns a mutable reference to the value in the entry.
Sourcepub fn and_modify<F>(self, f: F) -> Self
pub fn and_modify<F>(self, f: F) -> Self
Provides in-place mutable access to an occupied entry before any potential inserts into the tree.
Sourcepub fn move_backward(self) -> Result<OccupiedEntry<'a, K, V>, Self>
pub fn move_backward(self) -> Result<OccupiedEntry<'a, K, V>, Self>
Move to previous OccupiedEntry
When reaching the front, return the original entry in Err()
Sourcepub fn move_forward(self) -> Result<OccupiedEntry<'a, K, V>, Self>
pub fn move_forward(self) -> Result<OccupiedEntry<'a, K, V>, Self>
Move to next OccupiedEntry
When reaching the end, return the original entry in Err()
Sourcepub fn peak_backward(&self) -> Option<(&'a K, &'a V)>
pub fn peak_backward(&self) -> Option<(&'a K, &'a V)>
Peak previous OccupiedEntry
Sourcepub fn peak_forward(&self) -> Option<(&'a K, &'a V)>
pub fn peak_forward(&self) -> Option<(&'a K, &'a V)>
Peak the next OccupiedEntry
Trait Implementations§
Auto Trait Implementations§
impl<'a, K, V> Freeze for Entry<'a, K, V>where
K: Freeze,
impl<'a, K, V> RefUnwindSafe for Entry<'a, K, V>where
K: RefUnwindSafe,
impl<'a, K, V> !Send for Entry<'a, K, V>
impl<'a, K, V> !Sync for Entry<'a, K, V>
impl<'a, K, V> Unpin for Entry<'a, K, V>where
K: Unpin,
impl<'a, K, V> UnsafeUnpin for Entry<'a, K, V>where
K: UnsafeUnpin,
impl<'a, K, V> !UnwindSafe for Entry<'a, K, V>
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