pub struct AbsentEntry<'a, T, A = Global>where
    A: Allocator,
{ /* private fields */ }
Expand description

Type representing the absence of an entry, as returned by HashTable::find_entry.

This type only exists due to limitations in Rust’s NLL borrow checker. In the future, find_entry will return an Option<OccupiedEntry> and this type will be removed.

Examples

use ahash::AHasher;
use hashbrown::hash_table::{AbsentEntry, Entry, HashTable};
use std::hash::{BuildHasher, BuildHasherDefault};

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

let entry_v: AbsentEntry<_, _> = table.find_entry(hasher(&"a"), |&x| x == "a").unwrap_err();
entry_v
    .into_table()
    .insert_unique(hasher(&"a"), "a", hasher);
assert!(table.find(hasher(&"a"), |&x| x == "a").is_some() && table.len() == 1);

// Nonexistent key (insert)
match table.entry(hasher(&"b"), |&x| x == "b", hasher) {
    Entry::Vacant(view) => {
        view.insert("b");
    }
    Entry::Occupied(_) => unreachable!(),
}
assert!(table.find(hasher(&"b"), |&x| x == "b").is_some() && table.len() == 2);

Implementations

Converts the AbsentEntry into a mutable reference to the underlying table.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.