pub enum Entry<'t, 'e, P, A>where
P: LeafPolicy,
A: TreeAllocator<P>,{
Occupied(OccupiedEntry<'t, 'e, P, A>),
Vacant(VacantEntry<'t, 'e, P, A>),
}Expand description
A view into a single entry in a tree, which may either be vacant or occupied.
§Example
use masstree::MassTree;
let tree: MassTree<u64> = MassTree::new();
let guard = tree.guard();
// Insert if absent, get value either way
let _value = tree.entry_with_guard(b"counter", &guard)
.or_insert(0);
// Modify existing or insert default
let _value = tree.entry_with_guard(b"counter", &guard)
.and_modify(|v| v + 1)
.or_insert(0);Variants§
Occupied(OccupiedEntry<'t, 'e, P, A>)
An occupied entry (key exists in tree at classification time).
Vacant(VacantEntry<'t, 'e, P, A>)
A vacant entry (key does not exist classification time).
Implementations§
Source§impl<'t, 'e, P, A> Entry<'t, 'e, P, A>where
P: LeafPolicy,
A: TreeAllocator<P>,
impl<'t, 'e, P, A> Entry<'t, 'e, P, A>where
P: LeafPolicy,
A: TreeAllocator<P>,
Sourcepub fn or_insert(self, default: P::Value) -> P::Output
pub fn or_insert(self, default: P::Value) -> P::Output
Fallible version or_insert.
§Errors
Panics if insertion fails (allocation error). For fallible insertion,
use or_try_insert.
§Example
let value = tree.entry_with_guard(b"key", &guard).or_insert(42);Returns the entry’s value if occupied, or inserts the default and returns it.
Sourcepub fn or_insert_with<F>(self, default: F) -> P::Output
pub fn or_insert_with<F>(self, default: F) -> P::Output
Returns the entry’s value if occupied, or computes and inserts a default.
Sourcepub fn or_insert_with_key<F>(self, default: F) -> P::Output
pub fn or_insert_with_key<F>(self, default: F) -> P::Output
Returns the entry’s value if occupied, or computes a default from the key.
Sourcepub fn or_default(self) -> P::Output
pub fn or_default(self) -> P::Output
Inserts the default value if vacant, returns the entry’s value.
Sourcepub fn and_modify<F>(self, f: F) -> Self
pub fn and_modify<F>(self, f: F) -> Self
Modifies the value if occupied using the provided function.
Sourcepub fn insert_entry(self, value: P::Value) -> OccupiedEntry<'t, 'e, P, A>
pub fn insert_entry(self, value: P::Value) -> OccupiedEntry<'t, 'e, P, A>
Inserts a value and returns an OccupiedEntry.
Trait Implementations§
Auto Trait Implementations§
impl<'t, 'e, P, A> Freeze for Entry<'t, 'e, P, A>
impl<'t, 'e, P, A> !RefUnwindSafe for Entry<'t, 'e, P, A>
impl<'t, 'e, P, A> !Send for Entry<'t, 'e, P, A>
impl<'t, 'e, P, A> !Sync for Entry<'t, 'e, P, A>
impl<'t, 'e, P, A> Unpin for Entry<'t, 'e, P, A>
impl<'t, 'e, P, A> UnsafeUnpin for Entry<'t, 'e, P, A>
impl<'t, 'e, P, A> !UnwindSafe for Entry<'t, 'e, P, A>
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