pub struct VacantEntry<'a, P, Tag, K>{ /* private fields */ }Expand description
§Examples
use embed_avl::{AvlTree, AvlItem, AvlNode, Entry};
use core::cell::UnsafeCell;
use core::borrow::Borrow;
extern crate alloc;
use alloc::sync::Arc;
struct MyNode {
value: i32,
avl_node: UnsafeCell<AvlNode<MyNode, ()>>,
}
unsafe impl AvlItem<()> for MyNode {
fn get_node(&self) -> &mut AvlNode<MyNode, ()> {
unsafe { &mut *self.avl_node.get() }
}
}
impl Borrow<i32> for MyNode {
fn borrow(&self) -> &i32 {
&self.value
}
}
let mut tree = AvlTree::<Arc<MyNode>, ()>::new();
let key = 42;
if let Entry::Vacant(ent) = tree.entry(key) {
ent.insert_node(Arc::new(MyNode {
value: key,
avl_node: UnsafeCell::new(Default::default()),
}));
}Implementations§
Source§impl<'a, P, Tag, K> VacantEntry<'a, P, Tag, K>
impl<'a, P, Tag, K> VacantEntry<'a, P, Tag, K>
pub fn peek_prev(&self) -> Option<&P::Target>
pub fn key(&self) -> &K
pub fn peek_next(&self) -> Option<&P::Target>
pub fn move_prev(self) -> Option<OccupiedEntry<'a, P, Tag>>
pub fn move_next(self) -> Option<OccupiedEntry<'a, P, Tag>>
Sourcepub unsafe fn insert_node_unchecked(
self,
new_node: P,
) -> OccupiedEntry<'a, P, Tag>
pub unsafe fn insert_node_unchecked( self, new_node: P, ) -> OccupiedEntry<'a, P, Tag>
§Safety
Caller should make sure new_node have the same value to the search key to entry(),
ignoring K captured in VacantEntry
Source§impl<'a, P, Tag, K> VacantEntry<'a, P, Tag, K>
impl<'a, P, Tag, K> VacantEntry<'a, P, Tag, K>
Sourcepub fn insert_node(self, new_node: P) -> OccupiedEntry<'a, P, Tag>
pub fn insert_node(self, new_node: P) -> OccupiedEntry<'a, P, Tag>
insert new_node at the position, for entry search by borrowed key
§Safety
We have debug_assert_eq the key an the node
Auto Trait Implementations§
impl<'a, P, Tag, K> !Send for VacantEntry<'a, P, Tag, K>
impl<'a, P, Tag, K> !Sync for VacantEntry<'a, P, Tag, K>
impl<'a, P, Tag, K> !UnwindSafe for VacantEntry<'a, P, Tag, K>
impl<'a, P, Tag, K> Freeze for VacantEntry<'a, P, Tag, K>
impl<'a, P, Tag, K> RefUnwindSafe for VacantEntry<'a, P, Tag, K>where
<P as Pointer>::Target: Sized,
*mut <P as Pointer>::Target: RefUnwindSafe,
&'a mut AvlTree<P, Tag>: RefUnwindSafe,
K: RefUnwindSafe,
impl<'a, P, Tag, K> Unpin for VacantEntry<'a, P, Tag, K>
impl<'a, P, Tag, K> UnsafeUnpin for VacantEntry<'a, P, Tag, K>where
<P as Pointer>::Target: Sized,
*mut <P as Pointer>::Target: UnsafeUnpin,
&'a mut AvlTree<P, Tag>: UnsafeUnpin,
K: UnsafeUnpin,
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