pub struct VacantEntry<'a, T, A = Global>{ /* private fields */ }
🔬This is a nightly-only experimental API. (
btree_set_entry
#133549)Expand description
A view into a vacant entry in a BTreeSet
.
It is part of the Entry
enum.
§Examples
#![feature(btree_set_entry)]
use std::collections::btree_set::{Entry, BTreeSet};
let mut set = BTreeSet::<&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);
Implementations§
Source§impl<'a, T, A> VacantEntry<'a, T, A>
impl<'a, T, A> VacantEntry<'a, T, A>
Sourcepub fn get(&self) -> &T
🔬This is a nightly-only experimental API. (btree_set_entry
#133549)
pub fn get(&self) -> &T
btree_set_entry
#133549)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. (btree_set_entry
#133549)
pub fn into_value(self) -> T
btree_set_entry
#133549)Take ownership of the value.
§Examples
Trait Implementations§
Auto Trait Implementations§
impl<'a, T, A> Freeze for VacantEntry<'a, T, A>
impl<'a, T, A> RefUnwindSafe for VacantEntry<'a, T, A>where
T: RefUnwindSafe,
A: RefUnwindSafe,
impl<'a, T, A> Send for VacantEntry<'a, T, A>
impl<'a, T, A> Sync for VacantEntry<'a, T, A>
impl<'a, T, A> Unpin for VacantEntry<'a, T, A>
impl<'a, T, A = Global> !UnwindSafe for VacantEntry<'a, T, 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