pub struct OccupiedEntry<'a, T, S, A = Global>where
A: Allocator,{ /* private fields */ }Expand description
A view into an occupied entry in a HashSet.
It is part of the Entry enum.
§Examples
use rune::alloc::hash_set::{Entry, HashSet, OccupiedEntry};
use rune::alloc::prelude::*;
let mut set = HashSet::new();
set.try_extend(["a", "b", "c"])?;
let _entry_o: OccupiedEntry<_, _> = set.entry("a").try_insert()?;
assert_eq!(set.len(), 3);
// Existing key
match set.entry("a") {
Entry::Vacant(_) => unreachable!(),
Entry::Occupied(view) => {
assert_eq!(view.get(), &"a");
}
}
assert_eq!(set.len(), 3);
// Existing key (take)
match set.entry("c") {
Entry::Vacant(_) => unreachable!(),
Entry::Occupied(view) => {
assert_eq!(view.remove(), "c");
}
}
assert_eq!(set.get(&"c"), None);
assert_eq!(set.len(), 2);Auto Trait Implementations§
impl<'a, T, S, A> Freeze for OccupiedEntry<'a, T, S, A>where
T: Freeze,
impl<'a, T, S, A> RefUnwindSafe for OccupiedEntry<'a, T, S, A>
impl<'a, T, S, A> Send for OccupiedEntry<'a, T, S, A>
impl<'a, T, S, A> Sync for OccupiedEntry<'a, T, S, A>
impl<'a, T, S, A> Unpin for OccupiedEntry<'a, T, S, A>where
T: Unpin,
impl<'a, T, S, A = Global> !UnwindSafe for OccupiedEntry<'a, T, S, 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