Struct VacantEntry

struct VacantEntry<'a, T> { ... }

A handle to a vacant entry in a Slab.

VacantEntry allows constructing values with the key that they will be assigned to.

Examples

# use slab::*;
let mut slab = Slab::new();

let hello = {
    let entry = slab.vacant_entry();
    let key = entry.key();

    entry.insert((key, "hello"));
    key
};

assert_eq!(hello, slab[hello].0);
assert_eq!("hello", slab[hello].1);

Implementations

impl<'a, T> VacantEntry<'a, T>

fn insert(self: Self, val: T) -> &'a mut T

Insert a value in the entry, returning a mutable reference to the value.

To get the key associated with the value, use key prior to calling insert.

Examples

# use slab::*;
let mut slab = Slab::new();

let hello = {
    let entry = slab.vacant_entry();
    let key = entry.key();

    entry.insert((key, "hello"));
    key
};

assert_eq!(hello, slab[hello].0);
assert_eq!("hello", slab[hello].1);
fn key(self: &Self) -> usize

Return the key associated with this entry.

A value stored in this entry will be associated with this key.

Examples

# use slab::*;
let mut slab = Slab::new();

let hello = {
    let entry = slab.vacant_entry();
    let key = entry.key();

    entry.insert((key, "hello"));
    key
};

assert_eq!(hello, slab[hello].0);
assert_eq!("hello", slab[hello].1);

impl<'a, T> Freeze for VacantEntry<'a, T>

impl<'a, T> RefUnwindSafe for VacantEntry<'a, T>

impl<'a, T> Send for VacantEntry<'a, T>

impl<'a, T> Sync for VacantEntry<'a, T>

impl<'a, T> Unpin for VacantEntry<'a, T>

impl<'a, T> UnsafeUnpin for VacantEntry<'a, T>

impl<'a, T> UnwindSafe for VacantEntry<'a, T>

impl<'a, T: $crate::fmt::Debug> Debug for VacantEntry<'a, T>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T> Any for VacantEntry<'a, T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for VacantEntry<'a, T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for VacantEntry<'a, T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for VacantEntry<'a, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for VacantEntry<'a, T>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for VacantEntry<'a, T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for VacantEntry<'a, T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>