pub struct VacantEntry<'a, T, S, A: Allocator = Global> {
base: VacantEntry<'a, T, S, A>,
}🔬This is a nightly-only experimental API. (
hash_set_entry #60896)Expand description
A view into a vacant entry in a HashSet.
It is part of the Entry enum.
§Examples
#![feature(hash_set_entry)]
use std::collections::hash_set::{Entry, HashSet};
let mut set = HashSet::<&str>::new();
let entry_v = match set.entry("a") {
Entry::Vacant(view) => view,
Entry::Occupied(_) => unreachable!(),
};
entry_v.insert();
assert!(set.contains("a") && set.len() == 1);
// Nonexistent key (insert)
match set.entry("b") {
Entry::Vacant(view) => view.insert(),
Entry::Occupied(_) => unreachable!(),
}
assert!(set.contains("b") && set.len() == 2);Fields§
§base: VacantEntry<'a, T, S, A>🔬This is a nightly-only experimental API. (
hash_set_entry #60896)Implementations§
Source§impl<'a, T, S, A: Allocator> VacantEntry<'a, T, S, A>
impl<'a, T, S, A: Allocator> VacantEntry<'a, T, S, A>
Sourcepub fn get(&self) -> &T
🔬This is a nightly-only experimental API. (hash_set_entry #60896)
pub fn get(&self) -> &T
hash_set_entry #60896)Gets a reference to the value that would be used when inserting
through the VacantEntry.
§Examples
Sourcepub fn into_value(self) -> T
🔬This is a nightly-only experimental API. (hash_set_entry #60896)
pub fn into_value(self) -> T
hash_set_entry #60896)Take ownership of the value.
§Examples
Sourcepub fn insert(self)where
T: Hash,
S: BuildHasher,
🔬This is a nightly-only experimental API. (hash_set_entry #60896)
pub fn insert(self)where
T: Hash,
S: BuildHasher,
hash_set_entry #60896)Sets the value of the entry with the VacantEntry’s value.
§Examples
fn insert_entry(self) -> OccupiedEntry<'a, T, S, A>where
T: Hash,
S: BuildHasher,
Trait Implementations§
Auto Trait Implementations§
impl<'a, T, S, A> Freeze for VacantEntry<'a, T, S, A>where
T: Freeze,
impl<'a, T, S, A> RefUnwindSafe for VacantEntry<'a, T, S, A>
impl<'a, T, S, A> Send for VacantEntry<'a, T, S, A>
impl<'a, T, S, A> Sync for VacantEntry<'a, T, S, A>
impl<'a, T, S, A> Unpin for VacantEntry<'a, T, S, A>where
T: Unpin,
impl<'a, T, S, A> UnsafeUnpin for VacantEntry<'a, T, S, A>where
T: UnsafeUnpin,
impl<'a, T, S, A = Global> !UnwindSafe for VacantEntry<'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
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
🔬This is a nightly-only experimental API. (
ptr_alignment_type #102070)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)The largest safe length for a
[Self]. Read more