Skip to main content

MutEntry

Type Alias MutEntry 

Source
pub type MutEntry<'a, T> = Entry<'a, T>;
Expand description

A view into a single entry in a mutable table, which may either be vacant or occupied.

Aliased Type§

pub enum MutEntry<'a, T> {
    Occupied(OccupiedEntry<'a, T>),
    Vacant(VacantEntry<'a, T>),
}

Variants§

§

Occupied(OccupiedEntry<'a, T>)

An occupied entry.

§Examples

use hashbrown::hash_table::{Entry, OccupiedEntry};
use hashbrown::{HashTable, DefaultHashBuilder};
use std::hash::BuildHasher;

let mut table = HashTable::new();
let hasher = DefaultHashBuilder::default();
let hasher = |val: &_| hasher.hash_one(val);
for x in ["a", "b"] {
    table.insert_unique(hasher(&x), x, hasher);
}

match table.entry(hasher(&"a"), |&x| x == "a", hasher) {
    Entry::Vacant(_) => unreachable!(),
    Entry::Occupied(_) => {}
}
§

Vacant(VacantEntry<'a, T>)

A vacant entry.

§Examples

use hashbrown::hash_table::{Entry, OccupiedEntry};
use hashbrown::{HashTable, DefaultHashBuilder};
use std::hash::BuildHasher;

let mut table = HashTable::<&str>::new();
let hasher = DefaultHashBuilder::default();
let hasher = |val: &_| hasher.hash_one(val);

match table.entry(hasher(&"a"), |&x| x == "a", hasher) {
    Entry::Vacant(_) => {}
    Entry::Occupied(_) => unreachable!(),
}